Remove WolfSSL-FIPS-Ready source code and Demo
The WolfSSL-FIPS-Ready distribution is licensed under the GPLv3 or a commercial license. Only MIT licensed code is allowed in this repository. Refer to the FreeRTOS_Plus_WolfSSL_Windows_Simulator Demo for future WolfSSL integrations.pull/1071/head^2
parent
79180cde2d
commit
537007d96c
@ -1,301 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup Label="ProjectConfigurations">
|
||||
<ProjectConfiguration Include="Debug|Win32">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|Win32">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Debug|x64">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|x64">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="..\..\ThirdParty\WolfSSL-FIPS-Ready\src\crl.c" />
|
||||
<ClCompile Include="..\..\ThirdParty\WolfSSL-FIPS-Ready\src\internal.c" />
|
||||
<ClCompile Include="..\..\ThirdParty\WolfSSL-FIPS-Ready\src\keys.c" />
|
||||
<ClCompile Include="..\..\ThirdParty\WolfSSL-FIPS-Ready\src\ocsp.c" />
|
||||
<ClCompile Include="..\..\ThirdParty\WolfSSL-FIPS-Ready\src\sniffer.c" />
|
||||
<ClCompile Include="..\..\ThirdParty\WolfSSL-FIPS-Ready\src\ssl.c" />
|
||||
<ClCompile Include="..\..\ThirdParty\WolfSSL-FIPS-Ready\src\tls.c" />
|
||||
<ClCompile Include="..\..\ThirdParty\WolfSSL-FIPS-Ready\src\tls13.c" />
|
||||
<ClCompile Include="..\..\ThirdParty\WolfSSL-FIPS-Ready\src\wolfio.c" />
|
||||
<ClCompile Include="..\..\ThirdParty\WolfSSL-FIPS-Ready\wolfcrypt\src\aes.c" />
|
||||
<ClCompile Include="..\..\ThirdParty\WolfSSL-FIPS-Ready\wolfcrypt\src\arc4.c" />
|
||||
<ClCompile Include="..\..\ThirdParty\WolfSSL-FIPS-Ready\wolfcrypt\src\asm.c" />
|
||||
<ClCompile Include="..\..\ThirdParty\WolfSSL-FIPS-Ready\wolfcrypt\src\asn.c" />
|
||||
<ClCompile Include="..\..\ThirdParty\WolfSSL-FIPS-Ready\wolfcrypt\src\async.c" />
|
||||
<ClCompile Include="..\..\ThirdParty\WolfSSL-FIPS-Ready\wolfcrypt\src\blake2b.c" />
|
||||
<ClCompile Include="..\..\ThirdParty\WolfSSL-FIPS-Ready\wolfcrypt\src\blake2s.c" />
|
||||
<ClCompile Include="..\..\ThirdParty\WolfSSL-FIPS-Ready\wolfcrypt\src\camellia.c" />
|
||||
<ClCompile Include="..\..\ThirdParty\WolfSSL-FIPS-Ready\wolfcrypt\src\chacha.c" />
|
||||
<ClCompile Include="..\..\ThirdParty\WolfSSL-FIPS-Ready\wolfcrypt\src\chacha20_poly1305.c" />
|
||||
<ClCompile Include="..\..\ThirdParty\WolfSSL-FIPS-Ready\wolfcrypt\src\cmac.c" />
|
||||
<ClCompile Include="..\..\ThirdParty\WolfSSL-FIPS-Ready\wolfcrypt\src\coding.c" />
|
||||
<ClCompile Include="..\..\ThirdParty\WolfSSL-FIPS-Ready\wolfcrypt\src\compress.c" />
|
||||
<ClCompile Include="..\..\ThirdParty\WolfSSL-FIPS-Ready\wolfcrypt\src\cpuid.c" />
|
||||
<ClCompile Include="..\..\ThirdParty\WolfSSL-FIPS-Ready\wolfcrypt\src\cryptocb.c" />
|
||||
<ClCompile Include="..\..\ThirdParty\WolfSSL-FIPS-Ready\wolfcrypt\src\curve25519.c" />
|
||||
<ClCompile Include="..\..\ThirdParty\WolfSSL-FIPS-Ready\wolfcrypt\src\curve448.c" />
|
||||
<ClCompile Include="..\..\ThirdParty\WolfSSL-FIPS-Ready\wolfcrypt\src\des3.c" />
|
||||
<ClCompile Include="..\..\ThirdParty\WolfSSL-FIPS-Ready\wolfcrypt\src\dh.c" />
|
||||
<ClCompile Include="..\..\ThirdParty\WolfSSL-FIPS-Ready\wolfcrypt\src\dsa.c" />
|
||||
<ClCompile Include="..\..\ThirdParty\WolfSSL-FIPS-Ready\wolfcrypt\src\ecc.c" />
|
||||
<ClCompile Include="..\..\ThirdParty\WolfSSL-FIPS-Ready\wolfcrypt\src\ecc_fp.c" />
|
||||
<ClCompile Include="..\..\ThirdParty\WolfSSL-FIPS-Ready\wolfcrypt\src\ed25519.c" />
|
||||
<ClCompile Include="..\..\ThirdParty\WolfSSL-FIPS-Ready\wolfcrypt\src\ed448.c" />
|
||||
<ClCompile Include="..\..\ThirdParty\WolfSSL-FIPS-Ready\wolfcrypt\src\error.c" />
|
||||
<ClCompile Include="..\..\ThirdParty\WolfSSL-FIPS-Ready\wolfcrypt\src\evp.c" />
|
||||
<ClCompile Include="..\..\ThirdParty\WolfSSL-FIPS-Ready\wolfcrypt\src\fe_448.c" />
|
||||
<ClCompile Include="..\..\ThirdParty\WolfSSL-FIPS-Ready\wolfcrypt\src\fe_low_mem.c" />
|
||||
<ClCompile Include="..\..\ThirdParty\WolfSSL-FIPS-Ready\wolfcrypt\src\fe_operations.c" />
|
||||
<ClCompile Include="..\..\ThirdParty\WolfSSL-FIPS-Ready\wolfcrypt\src\fips.c" />
|
||||
<ClCompile Include="..\..\ThirdParty\WolfSSL-FIPS-Ready\wolfcrypt\src\fips_test.c" />
|
||||
<ClCompile Include="..\..\ThirdParty\WolfSSL-FIPS-Ready\wolfcrypt\src\ge_448.c" />
|
||||
<ClCompile Include="..\..\ThirdParty\WolfSSL-FIPS-Ready\wolfcrypt\src\ge_low_mem.c" />
|
||||
<ClCompile Include="..\..\ThirdParty\WolfSSL-FIPS-Ready\wolfcrypt\src\ge_operations.c" />
|
||||
<ClCompile Include="..\..\ThirdParty\WolfSSL-FIPS-Ready\wolfcrypt\src\hash.c" />
|
||||
<ClCompile Include="..\..\ThirdParty\WolfSSL-FIPS-Ready\wolfcrypt\src\hc128.c" />
|
||||
<ClCompile Include="..\..\ThirdParty\WolfSSL-FIPS-Ready\wolfcrypt\src\hmac.c" />
|
||||
<ClCompile Include="..\..\ThirdParty\WolfSSL-FIPS-Ready\wolfcrypt\src\idea.c" />
|
||||
<ClCompile Include="..\..\ThirdParty\WolfSSL-FIPS-Ready\wolfcrypt\src\integer.c" />
|
||||
<ClCompile Include="..\..\ThirdParty\WolfSSL-FIPS-Ready\wolfcrypt\src\logging.c" />
|
||||
<ClCompile Include="..\..\ThirdParty\WolfSSL-FIPS-Ready\wolfcrypt\src\md2.c" />
|
||||
<ClCompile Include="..\..\ThirdParty\WolfSSL-FIPS-Ready\wolfcrypt\src\md4.c" />
|
||||
<ClCompile Include="..\..\ThirdParty\WolfSSL-FIPS-Ready\wolfcrypt\src\md5.c" />
|
||||
<ClCompile Include="..\..\ThirdParty\WolfSSL-FIPS-Ready\wolfcrypt\src\memory.c" />
|
||||
<ClCompile Include="..\..\ThirdParty\WolfSSL-FIPS-Ready\wolfcrypt\src\misc.c" />
|
||||
<ClCompile Include="..\..\ThirdParty\WolfSSL-FIPS-Ready\wolfcrypt\src\pkcs12.c" />
|
||||
<ClCompile Include="..\..\ThirdParty\WolfSSL-FIPS-Ready\wolfcrypt\src\pkcs7.c" />
|
||||
<ClCompile Include="..\..\ThirdParty\WolfSSL-FIPS-Ready\wolfcrypt\src\poly1305.c" />
|
||||
<ClCompile Include="..\..\ThirdParty\WolfSSL-FIPS-Ready\wolfcrypt\src\pwdbased.c" />
|
||||
<ClCompile Include="..\..\ThirdParty\WolfSSL-FIPS-Ready\wolfcrypt\src\rabbit.c" />
|
||||
<ClCompile Include="..\..\ThirdParty\WolfSSL-FIPS-Ready\wolfcrypt\src\random.c" />
|
||||
<ClCompile Include="..\..\ThirdParty\WolfSSL-FIPS-Ready\wolfcrypt\src\ripemd.c" />
|
||||
<ClCompile Include="..\..\ThirdParty\WolfSSL-FIPS-Ready\wolfcrypt\src\rsa.c" />
|
||||
<ClCompile Include="..\..\ThirdParty\WolfSSL-FIPS-Ready\wolfcrypt\src\selftest.c" />
|
||||
<ClCompile Include="..\..\ThirdParty\WolfSSL-FIPS-Ready\wolfcrypt\src\sha.c" />
|
||||
<ClCompile Include="..\..\ThirdParty\WolfSSL-FIPS-Ready\wolfcrypt\src\sha256.c" />
|
||||
<ClCompile Include="..\..\ThirdParty\WolfSSL-FIPS-Ready\wolfcrypt\src\sha3.c" />
|
||||
<ClCompile Include="..\..\ThirdParty\WolfSSL-FIPS-Ready\wolfcrypt\src\sha512.c" />
|
||||
<ClCompile Include="..\..\ThirdParty\WolfSSL-FIPS-Ready\wolfcrypt\src\signature.c" />
|
||||
<ClCompile Include="..\..\ThirdParty\WolfSSL-FIPS-Ready\wolfcrypt\src\sp_arm32.c" />
|
||||
<ClCompile Include="..\..\ThirdParty\WolfSSL-FIPS-Ready\wolfcrypt\src\sp_arm64.c" />
|
||||
<ClCompile Include="..\..\ThirdParty\WolfSSL-FIPS-Ready\wolfcrypt\src\sp_armthumb.c" />
|
||||
<ClCompile Include="..\..\ThirdParty\WolfSSL-FIPS-Ready\wolfcrypt\src\sp_c32.c" />
|
||||
<ClCompile Include="..\..\ThirdParty\WolfSSL-FIPS-Ready\wolfcrypt\src\sp_c64.c" />
|
||||
<ClCompile Include="..\..\ThirdParty\WolfSSL-FIPS-Ready\wolfcrypt\src\sp_cortexm.c" />
|
||||
<ClCompile Include="..\..\ThirdParty\WolfSSL-FIPS-Ready\wolfcrypt\src\sp_dsp32.c" />
|
||||
<ClCompile Include="..\..\ThirdParty\WolfSSL-FIPS-Ready\wolfcrypt\src\sp_int.c" />
|
||||
<ClCompile Include="..\..\ThirdParty\WolfSSL-FIPS-Ready\wolfcrypt\src\sp_x86_64.c" />
|
||||
<ClCompile Include="..\..\ThirdParty\WolfSSL-FIPS-Ready\wolfcrypt\src\srp.c" />
|
||||
<ClCompile Include="..\..\ThirdParty\WolfSSL-FIPS-Ready\wolfcrypt\src\tfm.c" />
|
||||
<ClCompile Include="..\..\ThirdParty\WolfSSL-FIPS-Ready\wolfcrypt\src\wc_dsp.c" />
|
||||
<ClCompile Include="..\..\ThirdParty\WolfSSL-FIPS-Ready\wolfcrypt\src\wc_encrypt.c" />
|
||||
<ClCompile Include="..\..\ThirdParty\WolfSSL-FIPS-Ready\wolfcrypt\src\wc_pkcs11.c" />
|
||||
<ClCompile Include="..\..\ThirdParty\WolfSSL-FIPS-Ready\wolfcrypt\src\wc_port.c" />
|
||||
<ClCompile Include="..\..\ThirdParty\WolfSSL-FIPS-Ready\wolfcrypt\src\wolfcrypt_first.c" />
|
||||
<ClCompile Include="..\..\ThirdParty\WolfSSL-FIPS-Ready\wolfcrypt\src\wolfcrypt_last.c" />
|
||||
<ClCompile Include="..\..\ThirdParty\WolfSSL-FIPS-Ready\wolfcrypt\src\wolfevent.c" />
|
||||
<ClCompile Include="..\..\ThirdParty\WolfSSL-FIPS-Ready\wolfcrypt\src\wolfmath.c" />
|
||||
<ClCompile Include="main.c" />
|
||||
<ClCompile Include="SecureTCPClientTask.c" />
|
||||
<ClCompile Include="SecureTCPServerTask.c" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="..\..\ThirdParty\WolfSSL-FIPS-Ready\wolfcrypt\src\aes_asm.asm" />
|
||||
<None Include="..\..\ThirdParty\WolfSSL-FIPS-Ready\wolfcrypt\src\aes_asm.S" />
|
||||
<None Include="..\..\ThirdParty\WolfSSL-FIPS-Ready\wolfcrypt\src\aes_gcm_asm.S" />
|
||||
<None Include="..\..\ThirdParty\WolfSSL-FIPS-Ready\wolfcrypt\src\chacha_asm.S" />
|
||||
<None Include="..\..\ThirdParty\WolfSSL-FIPS-Ready\wolfcrypt\src\fe_x25519_128.i" />
|
||||
<None Include="..\..\ThirdParty\WolfSSL-FIPS-Ready\wolfcrypt\src\fe_x25519_asm.S" />
|
||||
<None Include="..\..\ThirdParty\WolfSSL-FIPS-Ready\wolfcrypt\src\fp_mont_small.i" />
|
||||
<None Include="..\..\ThirdParty\WolfSSL-FIPS-Ready\wolfcrypt\src\fp_mul_comba_12.i" />
|
||||
<None Include="..\..\ThirdParty\WolfSSL-FIPS-Ready\wolfcrypt\src\fp_mul_comba_17.i" />
|
||||
<None Include="..\..\ThirdParty\WolfSSL-FIPS-Ready\wolfcrypt\src\fp_mul_comba_20.i" />
|
||||
<None Include="..\..\ThirdParty\WolfSSL-FIPS-Ready\wolfcrypt\src\fp_mul_comba_24.i" />
|
||||
<None Include="..\..\ThirdParty\WolfSSL-FIPS-Ready\wolfcrypt\src\fp_mul_comba_28.i" />
|
||||
<None Include="..\..\ThirdParty\WolfSSL-FIPS-Ready\wolfcrypt\src\fp_mul_comba_3.i" />
|
||||
<None Include="..\..\ThirdParty\WolfSSL-FIPS-Ready\wolfcrypt\src\fp_mul_comba_32.i" />
|
||||
<None Include="..\..\ThirdParty\WolfSSL-FIPS-Ready\wolfcrypt\src\fp_mul_comba_4.i" />
|
||||
<None Include="..\..\ThirdParty\WolfSSL-FIPS-Ready\wolfcrypt\src\fp_mul_comba_48.i" />
|
||||
<None Include="..\..\ThirdParty\WolfSSL-FIPS-Ready\wolfcrypt\src\fp_mul_comba_6.i" />
|
||||
<None Include="..\..\ThirdParty\WolfSSL-FIPS-Ready\wolfcrypt\src\fp_mul_comba_64.i" />
|
||||
<None Include="..\..\ThirdParty\WolfSSL-FIPS-Ready\wolfcrypt\src\fp_mul_comba_7.i" />
|
||||
<None Include="..\..\ThirdParty\WolfSSL-FIPS-Ready\wolfcrypt\src\fp_mul_comba_8.i" />
|
||||
<None Include="..\..\ThirdParty\WolfSSL-FIPS-Ready\wolfcrypt\src\fp_mul_comba_9.i" />
|
||||
<None Include="..\..\ThirdParty\WolfSSL-FIPS-Ready\wolfcrypt\src\fp_mul_comba_small_set.i" />
|
||||
<None Include="..\..\ThirdParty\WolfSSL-FIPS-Ready\wolfcrypt\src\fp_sqr_comba_12.i" />
|
||||
<None Include="..\..\ThirdParty\WolfSSL-FIPS-Ready\wolfcrypt\src\fp_sqr_comba_17.i" />
|
||||
<None Include="..\..\ThirdParty\WolfSSL-FIPS-Ready\wolfcrypt\src\fp_sqr_comba_20.i" />
|
||||
<None Include="..\..\ThirdParty\WolfSSL-FIPS-Ready\wolfcrypt\src\fp_sqr_comba_24.i" />
|
||||
<None Include="..\..\ThirdParty\WolfSSL-FIPS-Ready\wolfcrypt\src\fp_sqr_comba_28.i" />
|
||||
<None Include="..\..\ThirdParty\WolfSSL-FIPS-Ready\wolfcrypt\src\fp_sqr_comba_3.i" />
|
||||
<None Include="..\..\ThirdParty\WolfSSL-FIPS-Ready\wolfcrypt\src\fp_sqr_comba_32.i" />
|
||||
<None Include="..\..\ThirdParty\WolfSSL-FIPS-Ready\wolfcrypt\src\fp_sqr_comba_4.i" />
|
||||
<None Include="..\..\ThirdParty\WolfSSL-FIPS-Ready\wolfcrypt\src\fp_sqr_comba_48.i" />
|
||||
<None Include="..\..\ThirdParty\WolfSSL-FIPS-Ready\wolfcrypt\src\fp_sqr_comba_6.i" />
|
||||
<None Include="..\..\ThirdParty\WolfSSL-FIPS-Ready\wolfcrypt\src\fp_sqr_comba_64.i" />
|
||||
<None Include="..\..\ThirdParty\WolfSSL-FIPS-Ready\wolfcrypt\src\fp_sqr_comba_7.i" />
|
||||
<None Include="..\..\ThirdParty\WolfSSL-FIPS-Ready\wolfcrypt\src\fp_sqr_comba_8.i" />
|
||||
<None Include="..\..\ThirdParty\WolfSSL-FIPS-Ready\wolfcrypt\src\fp_sqr_comba_9.i" />
|
||||
<None Include="..\..\ThirdParty\WolfSSL-FIPS-Ready\wolfcrypt\src\fp_sqr_comba_small_set.i" />
|
||||
<None Include="..\..\ThirdParty\WolfSSL-FIPS-Ready\wolfcrypt\src\include.am" />
|
||||
<None Include="..\..\ThirdParty\WolfSSL-FIPS-Ready\wolfcrypt\src\poly1305_asm.S" />
|
||||
<None Include="..\..\ThirdParty\WolfSSL-FIPS-Ready\wolfcrypt\src\sha256_asm.S" />
|
||||
<None Include="..\..\ThirdParty\WolfSSL-FIPS-Ready\wolfcrypt\src\sha512_asm.S" />
|
||||
<None Include="..\..\ThirdParty\WolfSSL-FIPS-Ready\wolfcrypt\src\sp_x86_64_asm.S" />
|
||||
<None Include="ca-cert.pem" />
|
||||
<None Include="server-cert.pem" />
|
||||
<None Include="server-key.pem" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="user_settings.h" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\VisualStudio_StaticProjects\FreeRTOS+TCP\FreeRTOS+TCP.vcxproj">
|
||||
<Project>{c90e6cc5-818b-4c97-8876-0986d989387c}</Project>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\..\VisualStudio_StaticProjects\FreeRTOS-Kernel\FreeRTOS-Kernel.vcxproj">
|
||||
<Project>{72c209c4-49a4-4942-a201-44706c9d77ec}</Project>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\..\VisualStudio_StaticProjects\Logging\Logging.vcxproj">
|
||||
<Project>{be362ac0-b10b-4276-b84e-6304652ba228}</Project>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<PropertyGroup Label="Globals">
|
||||
<VCProjectVersion>16.0</VCProjectVersion>
|
||||
<Keyword>Win32Proj</Keyword>
|
||||
<ProjectGuid>{60c50f90-c5b6-46e1-b41b-5c7b7c17be82}</ProjectGuid>
|
||||
<RootNamespace>FreeRTOSPlusWolfSSL</RootNamespace>
|
||||
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v142</PlatformToolset>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>v142</PlatformToolset>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v142</PlatformToolset>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>v142</PlatformToolset>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||
<ImportGroup Label="ExtensionSettings">
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="Shared">
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<LinkIncremental>true</LinkIncremental>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<LinkIncremental>true</LinkIncremental>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<PreprocessorDefinitions>WOLFSSL_USER_SETTINGS;_WINSOCK_DEPRECATED_NO_WARNINGS;_CRT_SECURE_NO_WARNINGS;WOLFSSL_IGNORE_FILE_WARN</PreprocessorDefinitions>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
<AdditionalIncludeDirectories>..\..\ThirdParty\WolfSSL-FIPS-Ready;.;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<PreprocessorDefinitions>WOLFSSL_USER_SETTINGS;_WINSOCK_DEPRECATED_NO_WARNINGS;_CRT_SECURE_NO_WARNINGS;WOLFSSL_IGNORE_FILE_WARN</PreprocessorDefinitions>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
<AdditionalIncludeDirectories>..\..\ThirdParty\WolfSSL-FIPS-Ready;.;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<PreprocessorDefinitions>WOLFSSL_USER_SETTINGS;_WINSOCK_DEPRECATED_NO_WARNINGS;_CRT_SECURE_NO_WARNINGS;WOLFSSL_IGNORE_FILE_WARN</PreprocessorDefinitions>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
<AdditionalIncludeDirectories>..\..\ThirdParty\WolfSSL-FIPS-Ready;.;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<PreprocessorDefinitions>WOLFSSL_USER_SETTINGS;_WINSOCK_DEPRECATED_NO_WARNINGS;_CRT_SECURE_NO_WARNINGS;WOLFSSL_IGNORE_FILE_WARN</PreprocessorDefinitions>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
<AdditionalIncludeDirectories>..\..\ThirdParty\WolfSSL-FIPS-Ready;.;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
</Project>
|
@ -1,437 +0,0 @@
|
||||
<?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;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="Header Files">
|
||||
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
|
||||
<Extensions>h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="Resource Files">
|
||||
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
|
||||
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="wolfSSL">
|
||||
<UniqueIdentifier>{56c6548d-8e4e-4531-b6d4-9bc1815c433b}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="wolfSSL\wolfcrypt">
|
||||
<UniqueIdentifier>{fc2c3fac-3ef3-4c68-be08-7dbf181b41c2}</UniqueIdentifier>
|
||||
</Filter>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="..\..\ThirdParty\WolfSSL-FIPS-Ready\wolfcrypt\src\aes.c">
|
||||
<Filter>wolfSSL\wolfcrypt</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\ThirdParty\WolfSSL-FIPS-Ready\wolfcrypt\src\arc4.c">
|
||||
<Filter>wolfSSL\wolfcrypt</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\ThirdParty\WolfSSL-FIPS-Ready\wolfcrypt\src\asm.c">
|
||||
<Filter>wolfSSL\wolfcrypt</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\ThirdParty\WolfSSL-FIPS-Ready\wolfcrypt\src\asn.c">
|
||||
<Filter>wolfSSL\wolfcrypt</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\ThirdParty\WolfSSL-FIPS-Ready\wolfcrypt\src\async.c">
|
||||
<Filter>wolfSSL\wolfcrypt</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\ThirdParty\WolfSSL-FIPS-Ready\wolfcrypt\src\blake2b.c">
|
||||
<Filter>wolfSSL\wolfcrypt</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\ThirdParty\WolfSSL-FIPS-Ready\wolfcrypt\src\blake2s.c">
|
||||
<Filter>wolfSSL\wolfcrypt</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\ThirdParty\WolfSSL-FIPS-Ready\wolfcrypt\src\camellia.c">
|
||||
<Filter>wolfSSL\wolfcrypt</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\ThirdParty\WolfSSL-FIPS-Ready\wolfcrypt\src\chacha.c">
|
||||
<Filter>wolfSSL\wolfcrypt</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\ThirdParty\WolfSSL-FIPS-Ready\wolfcrypt\src\chacha20_poly1305.c">
|
||||
<Filter>wolfSSL\wolfcrypt</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\ThirdParty\WolfSSL-FIPS-Ready\wolfcrypt\src\cmac.c">
|
||||
<Filter>wolfSSL\wolfcrypt</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\ThirdParty\WolfSSL-FIPS-Ready\wolfcrypt\src\coding.c">
|
||||
<Filter>wolfSSL\wolfcrypt</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\ThirdParty\WolfSSL-FIPS-Ready\wolfcrypt\src\compress.c">
|
||||
<Filter>wolfSSL\wolfcrypt</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\ThirdParty\WolfSSL-FIPS-Ready\wolfcrypt\src\cpuid.c">
|
||||
<Filter>wolfSSL\wolfcrypt</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\ThirdParty\WolfSSL-FIPS-Ready\wolfcrypt\src\cryptocb.c">
|
||||
<Filter>wolfSSL\wolfcrypt</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\ThirdParty\WolfSSL-FIPS-Ready\wolfcrypt\src\curve448.c">
|
||||
<Filter>wolfSSL\wolfcrypt</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\ThirdParty\WolfSSL-FIPS-Ready\wolfcrypt\src\curve25519.c">
|
||||
<Filter>wolfSSL\wolfcrypt</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\ThirdParty\WolfSSL-FIPS-Ready\wolfcrypt\src\des3.c">
|
||||
<Filter>wolfSSL\wolfcrypt</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\ThirdParty\WolfSSL-FIPS-Ready\wolfcrypt\src\dh.c">
|
||||
<Filter>wolfSSL\wolfcrypt</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\ThirdParty\WolfSSL-FIPS-Ready\wolfcrypt\src\dsa.c">
|
||||
<Filter>wolfSSL\wolfcrypt</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\ThirdParty\WolfSSL-FIPS-Ready\wolfcrypt\src\ecc.c">
|
||||
<Filter>wolfSSL\wolfcrypt</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\ThirdParty\WolfSSL-FIPS-Ready\wolfcrypt\src\ecc_fp.c">
|
||||
<Filter>wolfSSL\wolfcrypt</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\ThirdParty\WolfSSL-FIPS-Ready\wolfcrypt\src\ed448.c">
|
||||
<Filter>wolfSSL\wolfcrypt</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\ThirdParty\WolfSSL-FIPS-Ready\wolfcrypt\src\ed25519.c">
|
||||
<Filter>wolfSSL\wolfcrypt</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\ThirdParty\WolfSSL-FIPS-Ready\wolfcrypt\src\error.c">
|
||||
<Filter>wolfSSL\wolfcrypt</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\ThirdParty\WolfSSL-FIPS-Ready\wolfcrypt\src\evp.c">
|
||||
<Filter>wolfSSL\wolfcrypt</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\ThirdParty\WolfSSL-FIPS-Ready\wolfcrypt\src\fe_448.c">
|
||||
<Filter>wolfSSL\wolfcrypt</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\ThirdParty\WolfSSL-FIPS-Ready\wolfcrypt\src\fe_low_mem.c">
|
||||
<Filter>wolfSSL\wolfcrypt</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\ThirdParty\WolfSSL-FIPS-Ready\wolfcrypt\src\fe_operations.c">
|
||||
<Filter>wolfSSL\wolfcrypt</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\ThirdParty\WolfSSL-FIPS-Ready\wolfcrypt\src\fips.c">
|
||||
<Filter>wolfSSL\wolfcrypt</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\ThirdParty\WolfSSL-FIPS-Ready\wolfcrypt\src\fips_test.c">
|
||||
<Filter>wolfSSL\wolfcrypt</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\ThirdParty\WolfSSL-FIPS-Ready\wolfcrypt\src\ge_448.c">
|
||||
<Filter>wolfSSL\wolfcrypt</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\ThirdParty\WolfSSL-FIPS-Ready\wolfcrypt\src\ge_low_mem.c">
|
||||
<Filter>wolfSSL\wolfcrypt</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\ThirdParty\WolfSSL-FIPS-Ready\wolfcrypt\src\ge_operations.c">
|
||||
<Filter>wolfSSL\wolfcrypt</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\ThirdParty\WolfSSL-FIPS-Ready\wolfcrypt\src\hash.c">
|
||||
<Filter>wolfSSL\wolfcrypt</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\ThirdParty\WolfSSL-FIPS-Ready\wolfcrypt\src\hc128.c">
|
||||
<Filter>wolfSSL\wolfcrypt</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\ThirdParty\WolfSSL-FIPS-Ready\wolfcrypt\src\hmac.c">
|
||||
<Filter>wolfSSL\wolfcrypt</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\ThirdParty\WolfSSL-FIPS-Ready\wolfcrypt\src\idea.c">
|
||||
<Filter>wolfSSL\wolfcrypt</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\ThirdParty\WolfSSL-FIPS-Ready\wolfcrypt\src\integer.c">
|
||||
<Filter>wolfSSL\wolfcrypt</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\ThirdParty\WolfSSL-FIPS-Ready\wolfcrypt\src\logging.c">
|
||||
<Filter>wolfSSL\wolfcrypt</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\ThirdParty\WolfSSL-FIPS-Ready\wolfcrypt\src\md2.c">
|
||||
<Filter>wolfSSL\wolfcrypt</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\ThirdParty\WolfSSL-FIPS-Ready\wolfcrypt\src\md4.c">
|
||||
<Filter>wolfSSL\wolfcrypt</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\ThirdParty\WolfSSL-FIPS-Ready\wolfcrypt\src\md5.c">
|
||||
<Filter>wolfSSL\wolfcrypt</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\ThirdParty\WolfSSL-FIPS-Ready\wolfcrypt\src\memory.c">
|
||||
<Filter>wolfSSL\wolfcrypt</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\ThirdParty\WolfSSL-FIPS-Ready\wolfcrypt\src\misc.c">
|
||||
<Filter>wolfSSL\wolfcrypt</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\ThirdParty\WolfSSL-FIPS-Ready\wolfcrypt\src\pkcs7.c">
|
||||
<Filter>wolfSSL\wolfcrypt</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\ThirdParty\WolfSSL-FIPS-Ready\wolfcrypt\src\pkcs12.c">
|
||||
<Filter>wolfSSL\wolfcrypt</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\ThirdParty\WolfSSL-FIPS-Ready\wolfcrypt\src\poly1305.c">
|
||||
<Filter>wolfSSL\wolfcrypt</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\ThirdParty\WolfSSL-FIPS-Ready\wolfcrypt\src\pwdbased.c">
|
||||
<Filter>wolfSSL\wolfcrypt</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\ThirdParty\WolfSSL-FIPS-Ready\wolfcrypt\src\rabbit.c">
|
||||
<Filter>wolfSSL\wolfcrypt</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\ThirdParty\WolfSSL-FIPS-Ready\wolfcrypt\src\random.c">
|
||||
<Filter>wolfSSL\wolfcrypt</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\ThirdParty\WolfSSL-FIPS-Ready\wolfcrypt\src\ripemd.c">
|
||||
<Filter>wolfSSL\wolfcrypt</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\ThirdParty\WolfSSL-FIPS-Ready\wolfcrypt\src\rsa.c">
|
||||
<Filter>wolfSSL\wolfcrypt</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\ThirdParty\WolfSSL-FIPS-Ready\wolfcrypt\src\selftest.c">
|
||||
<Filter>wolfSSL\wolfcrypt</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\ThirdParty\WolfSSL-FIPS-Ready\wolfcrypt\src\sha.c">
|
||||
<Filter>wolfSSL\wolfcrypt</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\ThirdParty\WolfSSL-FIPS-Ready\wolfcrypt\src\sha3.c">
|
||||
<Filter>wolfSSL\wolfcrypt</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\ThirdParty\WolfSSL-FIPS-Ready\wolfcrypt\src\sha256.c">
|
||||
<Filter>wolfSSL\wolfcrypt</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\ThirdParty\WolfSSL-FIPS-Ready\wolfcrypt\src\sha512.c">
|
||||
<Filter>wolfSSL\wolfcrypt</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\ThirdParty\WolfSSL-FIPS-Ready\wolfcrypt\src\signature.c">
|
||||
<Filter>wolfSSL\wolfcrypt</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\ThirdParty\WolfSSL-FIPS-Ready\wolfcrypt\src\sp_arm32.c">
|
||||
<Filter>wolfSSL\wolfcrypt</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\ThirdParty\WolfSSL-FIPS-Ready\wolfcrypt\src\sp_arm64.c">
|
||||
<Filter>wolfSSL\wolfcrypt</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\ThirdParty\WolfSSL-FIPS-Ready\wolfcrypt\src\sp_armthumb.c">
|
||||
<Filter>wolfSSL\wolfcrypt</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\ThirdParty\WolfSSL-FIPS-Ready\wolfcrypt\src\sp_c32.c">
|
||||
<Filter>wolfSSL\wolfcrypt</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\ThirdParty\WolfSSL-FIPS-Ready\wolfcrypt\src\sp_c64.c">
|
||||
<Filter>wolfSSL\wolfcrypt</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\ThirdParty\WolfSSL-FIPS-Ready\wolfcrypt\src\sp_cortexm.c">
|
||||
<Filter>wolfSSL\wolfcrypt</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\ThirdParty\WolfSSL-FIPS-Ready\wolfcrypt\src\sp_dsp32.c">
|
||||
<Filter>wolfSSL\wolfcrypt</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\ThirdParty\WolfSSL-FIPS-Ready\wolfcrypt\src\sp_int.c">
|
||||
<Filter>wolfSSL\wolfcrypt</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\ThirdParty\WolfSSL-FIPS-Ready\wolfcrypt\src\sp_x86_64.c">
|
||||
<Filter>wolfSSL\wolfcrypt</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\ThirdParty\WolfSSL-FIPS-Ready\wolfcrypt\src\srp.c">
|
||||
<Filter>wolfSSL\wolfcrypt</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\ThirdParty\WolfSSL-FIPS-Ready\wolfcrypt\src\tfm.c">
|
||||
<Filter>wolfSSL\wolfcrypt</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\ThirdParty\WolfSSL-FIPS-Ready\wolfcrypt\src\wc_dsp.c">
|
||||
<Filter>wolfSSL\wolfcrypt</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\ThirdParty\WolfSSL-FIPS-Ready\wolfcrypt\src\wc_encrypt.c">
|
||||
<Filter>wolfSSL\wolfcrypt</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\ThirdParty\WolfSSL-FIPS-Ready\wolfcrypt\src\wc_pkcs11.c">
|
||||
<Filter>wolfSSL\wolfcrypt</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\ThirdParty\WolfSSL-FIPS-Ready\wolfcrypt\src\wc_port.c">
|
||||
<Filter>wolfSSL\wolfcrypt</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\ThirdParty\WolfSSL-FIPS-Ready\wolfcrypt\src\wolfcrypt_first.c">
|
||||
<Filter>wolfSSL\wolfcrypt</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\ThirdParty\WolfSSL-FIPS-Ready\wolfcrypt\src\wolfcrypt_last.c">
|
||||
<Filter>wolfSSL\wolfcrypt</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\ThirdParty\WolfSSL-FIPS-Ready\wolfcrypt\src\wolfevent.c">
|
||||
<Filter>wolfSSL\wolfcrypt</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\ThirdParty\WolfSSL-FIPS-Ready\wolfcrypt\src\wolfmath.c">
|
||||
<Filter>wolfSSL\wolfcrypt</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\ThirdParty\WolfSSL-FIPS-Ready\src\crl.c">
|
||||
<Filter>wolfSSL</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\ThirdParty\WolfSSL-FIPS-Ready\src\internal.c">
|
||||
<Filter>wolfSSL</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\ThirdParty\WolfSSL-FIPS-Ready\src\keys.c">
|
||||
<Filter>wolfSSL</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\ThirdParty\WolfSSL-FIPS-Ready\src\ocsp.c">
|
||||
<Filter>wolfSSL</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\ThirdParty\WolfSSL-FIPS-Ready\src\sniffer.c">
|
||||
<Filter>wolfSSL</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\ThirdParty\WolfSSL-FIPS-Ready\src\ssl.c">
|
||||
<Filter>wolfSSL</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\ThirdParty\WolfSSL-FIPS-Ready\src\tls.c">
|
||||
<Filter>wolfSSL</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\ThirdParty\WolfSSL-FIPS-Ready\src\tls13.c">
|
||||
<Filter>wolfSSL</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\ThirdParty\WolfSSL-FIPS-Ready\src\wolfio.c">
|
||||
<Filter>wolfSSL</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="main.c">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="SecureTCPClientTask.c">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="SecureTCPServerTask.c">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="..\..\ThirdParty\WolfSSL-FIPS-Ready\wolfcrypt\src\aes_asm.asm">
|
||||
<Filter>wolfSSL\wolfcrypt</Filter>
|
||||
</None>
|
||||
<None Include="..\..\ThirdParty\WolfSSL-FIPS-Ready\wolfcrypt\src\aes_asm.S">
|
||||
<Filter>wolfSSL\wolfcrypt</Filter>
|
||||
</None>
|
||||
<None Include="..\..\ThirdParty\WolfSSL-FIPS-Ready\wolfcrypt\src\aes_gcm_asm.S">
|
||||
<Filter>wolfSSL\wolfcrypt</Filter>
|
||||
</None>
|
||||
<None Include="..\..\ThirdParty\WolfSSL-FIPS-Ready\wolfcrypt\src\chacha_asm.S">
|
||||
<Filter>wolfSSL\wolfcrypt</Filter>
|
||||
</None>
|
||||
<None Include="..\..\ThirdParty\WolfSSL-FIPS-Ready\wolfcrypt\src\fe_x25519_128.i">
|
||||
<Filter>wolfSSL\wolfcrypt</Filter>
|
||||
</None>
|
||||
<None Include="..\..\ThirdParty\WolfSSL-FIPS-Ready\wolfcrypt\src\fe_x25519_asm.S">
|
||||
<Filter>wolfSSL\wolfcrypt</Filter>
|
||||
</None>
|
||||
<None Include="..\..\ThirdParty\WolfSSL-FIPS-Ready\wolfcrypt\src\fp_mont_small.i">
|
||||
<Filter>wolfSSL\wolfcrypt</Filter>
|
||||
</None>
|
||||
<None Include="..\..\ThirdParty\WolfSSL-FIPS-Ready\wolfcrypt\src\fp_mul_comba_3.i">
|
||||
<Filter>wolfSSL\wolfcrypt</Filter>
|
||||
</None>
|
||||
<None Include="..\..\ThirdParty\WolfSSL-FIPS-Ready\wolfcrypt\src\fp_mul_comba_4.i">
|
||||
<Filter>wolfSSL\wolfcrypt</Filter>
|
||||
</None>
|
||||
<None Include="..\..\ThirdParty\WolfSSL-FIPS-Ready\wolfcrypt\src\fp_mul_comba_6.i">
|
||||
<Filter>wolfSSL\wolfcrypt</Filter>
|
||||
</None>
|
||||
<None Include="..\..\ThirdParty\WolfSSL-FIPS-Ready\wolfcrypt\src\fp_mul_comba_7.i">
|
||||
<Filter>wolfSSL\wolfcrypt</Filter>
|
||||
</None>
|
||||
<None Include="..\..\ThirdParty\WolfSSL-FIPS-Ready\wolfcrypt\src\fp_mul_comba_8.i">
|
||||
<Filter>wolfSSL\wolfcrypt</Filter>
|
||||
</None>
|
||||
<None Include="..\..\ThirdParty\WolfSSL-FIPS-Ready\wolfcrypt\src\fp_mul_comba_9.i">
|
||||
<Filter>wolfSSL\wolfcrypt</Filter>
|
||||
</None>
|
||||
<None Include="..\..\ThirdParty\WolfSSL-FIPS-Ready\wolfcrypt\src\fp_mul_comba_12.i">
|
||||
<Filter>wolfSSL\wolfcrypt</Filter>
|
||||
</None>
|
||||
<None Include="..\..\ThirdParty\WolfSSL-FIPS-Ready\wolfcrypt\src\fp_mul_comba_17.i">
|
||||
<Filter>wolfSSL\wolfcrypt</Filter>
|
||||
</None>
|
||||
<None Include="..\..\ThirdParty\WolfSSL-FIPS-Ready\wolfcrypt\src\fp_mul_comba_20.i">
|
||||
<Filter>wolfSSL\wolfcrypt</Filter>
|
||||
</None>
|
||||
<None Include="..\..\ThirdParty\WolfSSL-FIPS-Ready\wolfcrypt\src\fp_mul_comba_24.i">
|
||||
<Filter>wolfSSL\wolfcrypt</Filter>
|
||||
</None>
|
||||
<None Include="..\..\ThirdParty\WolfSSL-FIPS-Ready\wolfcrypt\src\fp_mul_comba_28.i">
|
||||
<Filter>wolfSSL\wolfcrypt</Filter>
|
||||
</None>
|
||||
<None Include="..\..\ThirdParty\WolfSSL-FIPS-Ready\wolfcrypt\src\fp_mul_comba_32.i">
|
||||
<Filter>wolfSSL\wolfcrypt</Filter>
|
||||
</None>
|
||||
<None Include="..\..\ThirdParty\WolfSSL-FIPS-Ready\wolfcrypt\src\fp_mul_comba_48.i">
|
||||
<Filter>wolfSSL\wolfcrypt</Filter>
|
||||
</None>
|
||||
<None Include="..\..\ThirdParty\WolfSSL-FIPS-Ready\wolfcrypt\src\fp_mul_comba_64.i">
|
||||
<Filter>wolfSSL\wolfcrypt</Filter>
|
||||
</None>
|
||||
<None Include="..\..\ThirdParty\WolfSSL-FIPS-Ready\wolfcrypt\src\fp_mul_comba_small_set.i">
|
||||
<Filter>wolfSSL\wolfcrypt</Filter>
|
||||
</None>
|
||||
<None Include="..\..\ThirdParty\WolfSSL-FIPS-Ready\wolfcrypt\src\fp_sqr_comba_3.i">
|
||||
<Filter>wolfSSL\wolfcrypt</Filter>
|
||||
</None>
|
||||
<None Include="..\..\ThirdParty\WolfSSL-FIPS-Ready\wolfcrypt\src\fp_sqr_comba_4.i">
|
||||
<Filter>wolfSSL\wolfcrypt</Filter>
|
||||
</None>
|
||||
<None Include="..\..\ThirdParty\WolfSSL-FIPS-Ready\wolfcrypt\src\fp_sqr_comba_6.i">
|
||||
<Filter>wolfSSL\wolfcrypt</Filter>
|
||||
</None>
|
||||
<None Include="..\..\ThirdParty\WolfSSL-FIPS-Ready\wolfcrypt\src\fp_sqr_comba_7.i">
|
||||
<Filter>wolfSSL\wolfcrypt</Filter>
|
||||
</None>
|
||||
<None Include="..\..\ThirdParty\WolfSSL-FIPS-Ready\wolfcrypt\src\fp_sqr_comba_8.i">
|
||||
<Filter>wolfSSL\wolfcrypt</Filter>
|
||||
</None>
|
||||
<None Include="..\..\ThirdParty\WolfSSL-FIPS-Ready\wolfcrypt\src\fp_sqr_comba_9.i">
|
||||
<Filter>wolfSSL\wolfcrypt</Filter>
|
||||
</None>
|
||||
<None Include="..\..\ThirdParty\WolfSSL-FIPS-Ready\wolfcrypt\src\fp_sqr_comba_12.i">
|
||||
<Filter>wolfSSL\wolfcrypt</Filter>
|
||||
</None>
|
||||
<None Include="..\..\ThirdParty\WolfSSL-FIPS-Ready\wolfcrypt\src\fp_sqr_comba_17.i">
|
||||
<Filter>wolfSSL\wolfcrypt</Filter>
|
||||
</None>
|
||||
<None Include="..\..\ThirdParty\WolfSSL-FIPS-Ready\wolfcrypt\src\fp_sqr_comba_20.i">
|
||||
<Filter>wolfSSL\wolfcrypt</Filter>
|
||||
</None>
|
||||
<None Include="..\..\ThirdParty\WolfSSL-FIPS-Ready\wolfcrypt\src\fp_sqr_comba_24.i">
|
||||
<Filter>wolfSSL\wolfcrypt</Filter>
|
||||
</None>
|
||||
<None Include="..\..\ThirdParty\WolfSSL-FIPS-Ready\wolfcrypt\src\fp_sqr_comba_28.i">
|
||||
<Filter>wolfSSL\wolfcrypt</Filter>
|
||||
</None>
|
||||
<None Include="..\..\ThirdParty\WolfSSL-FIPS-Ready\wolfcrypt\src\fp_sqr_comba_32.i">
|
||||
<Filter>wolfSSL\wolfcrypt</Filter>
|
||||
</None>
|
||||
<None Include="..\..\ThirdParty\WolfSSL-FIPS-Ready\wolfcrypt\src\fp_sqr_comba_48.i">
|
||||
<Filter>wolfSSL\wolfcrypt</Filter>
|
||||
</None>
|
||||
<None Include="..\..\ThirdParty\WolfSSL-FIPS-Ready\wolfcrypt\src\fp_sqr_comba_64.i">
|
||||
<Filter>wolfSSL\wolfcrypt</Filter>
|
||||
</None>
|
||||
<None Include="..\..\ThirdParty\WolfSSL-FIPS-Ready\wolfcrypt\src\fp_sqr_comba_small_set.i">
|
||||
<Filter>wolfSSL\wolfcrypt</Filter>
|
||||
</None>
|
||||
<None Include="..\..\ThirdParty\WolfSSL-FIPS-Ready\wolfcrypt\src\include.am">
|
||||
<Filter>wolfSSL\wolfcrypt</Filter>
|
||||
</None>
|
||||
<None Include="..\..\ThirdParty\WolfSSL-FIPS-Ready\wolfcrypt\src\poly1305_asm.S">
|
||||
<Filter>wolfSSL\wolfcrypt</Filter>
|
||||
</None>
|
||||
<None Include="..\..\ThirdParty\WolfSSL-FIPS-Ready\wolfcrypt\src\sha256_asm.S">
|
||||
<Filter>wolfSSL\wolfcrypt</Filter>
|
||||
</None>
|
||||
<None Include="..\..\ThirdParty\WolfSSL-FIPS-Ready\wolfcrypt\src\sha512_asm.S">
|
||||
<Filter>wolfSSL\wolfcrypt</Filter>
|
||||
</None>
|
||||
<None Include="..\..\ThirdParty\WolfSSL-FIPS-Ready\wolfcrypt\src\sp_x86_64_asm.S">
|
||||
<Filter>wolfSSL\wolfcrypt</Filter>
|
||||
</None>
|
||||
<None Include="ca-cert.pem">
|
||||
<Filter>Header Files</Filter>
|
||||
</None>
|
||||
<None Include="server-cert.pem">
|
||||
<Filter>Header Files</Filter>
|
||||
</None>
|
||||
<None Include="server-key.pem">
|
||||
<Filter>Header Files</Filter>
|
||||
</None>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="user_settings.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
</Project>
|
@ -1,90 +0,0 @@
|
||||
# wolfSSL FIPS-Ready
|
||||
|
||||
# Overview
|
||||
Federal Information Processing Standards (FIPS) 140-2 specifies the security requirements that will be satisfied by a cryptographic module. It specifies that a cryptographic module should set a cryptographic boundary and mandates certain power-on selftest requirements such as an integrity check and cryptographic known answer tests.
|
||||
|
||||
wolfSSL FIPS Ready includes FIPS-enabled cryptography layer code along with the wolfSSL source code. It is not associated with a FIPS certificate, but allows applications to include the same FIPS-specific code (default entry point, power on self test) and best practices used by and required in FIPS-validated modules. If your project may need to get a FIPS certificate in the future, using the wolfSSL FIPS-Ready version now will accelerate future validation times. It makes your project FIPS-Ready and helps ensure best practices.
|
||||
|
||||
Next to this folder you will see another demo folder named "FreeRTOS_Plus_WolfSSL_Windows_Simulator". The demo uses regular (non-FIPS-Ready) wolfSSL. If you compare both demos, you will notice that there are no changes to the client code, and will also notice that some additional tests run prior to your main program in this FIPS-Ready demo.
|
||||
|
||||
This demo shows that wolfSSL FIPS Ready provides a FIPS compliant cryptographic module with minimal impact on client code.
|
||||
|
||||
# What does FIPS 140-2 specify?
|
||||
|
||||
FIPS 140-2 enforces cryptographic modules to follow best practices, including:
|
||||
|
||||
1. Removal of insecure algorithms (such as MD5 and DES)
|
||||
2. Include a default entry point
|
||||
3. Perform a Power On Self Test (POST)
|
||||
|
||||
wolfSSL FIPS Ready fulfils these requirements. The third requirement means that the POST should run automatically whenever the application using the FIPS code starts up. For wolfSSL FIPS Ready, the POST consits of two tests:
|
||||
|
||||
- In-Core Integrity Check (HMAC-SHA256 over cryptographic algorithm object files)
|
||||
- Known Answer Tests (KATs)
|
||||
|
||||
The in-core integrity check performs an HMAC-SHA256 operation over the object files included in the FIPS-compliant algorithm boundary. The cryptographic boundary is the FIPS-specific code and its related static data in the memory of the program. In the integrity check process, the calculated hash value is compared with the expexted pre-calculated value in the memory. Failure of this check means that compiled boundary code was modified after it was compiled. If either the integrity check or KAT fails, the module enters an error state.
|
||||
|
||||
The KAT (Known Answer Tests) run algorithm test cases using pre-computed NIST test vectors, thus verifying that the algorithms are working successfully. The KAT code and test vectors are inside the cryptographic boundary and are also checked as part of the in-core integrity check.
|
||||
|
||||
# How to build and run the Demo application
|
||||
|
||||
By double-clicking the solution file named "FreeRTOS_Plus_WolfSSL_FIPS_Ready.sln" included in this folder, Visual Studio starts and shows you a project in its solution explorer. It is named "RTOSDemo" and provides a console application program which runs on windows.
|
||||
|
||||
All required settings have been set in the user_settings.h header file included in the RTOSDemo/FreeRTOS+/wolfSSL folder in the solution explorer pane. The next step is to build the RTOSDemo application:
|
||||
|
||||
1. Build the RTOSDemo project
|
||||
2. Run the RTOSDemo.exe
|
||||
|
||||
You will see a console that pops up, and it shows output like the following:
|
||||
|
||||
# Self Test Explanation
|
||||
```
|
||||
Starting Power On Self Test
|
||||
In core integrity check error: hash = C66491A040D5B9686BAA7A75A280290D91B49...
|
||||
```
|
||||
|
||||
Do not worry about this result, an error is expected at this point. Error number "-203" means In-Core-integrity-check failed. The check is identical to the "In Core Integrity Test" listed in the previous section. And the subsequent KAT also failed due to the first error. Once FIPS Ready has failed POST, it enters an error state and never allows subsequent cryptographic operations until the device is restarted and the tests can complete successfully.
|
||||
|
||||
The in-core integrity check requires a pre-calculated hash value to be stored in the fips_test.c source file. Remember that you did not yet set this pre-calculated value during the build process. Because the hash does not match the stored value is the reason why this first run will fail.
|
||||
|
||||
# Update Pre-calculated hash value
|
||||
|
||||
1. Let us go back to the messages in the console shown in the previous section. You may see "hash = C66491A040..." in the message. **The charactor sequence is the value for the pre-calculated hash value.** Please copy this charactor sequece and store it in a temporary location for reference in the next step.
|
||||
|
||||
2. Find and open the file named "**fips_test.c**" under the RTOSDemo/FreeRTOS+/wolfSSL/wolfcrypt folder in the Visual Studio solution explorer pane. Or you can reach the file by traversing "../../ThirdParty/WolfSSL-FIPS-Ready/wolfcrypt/src/fips_test.c" starting from the folder where this README is included.
|
||||
|
||||
3. In the fips_test.c, find the following statement:
|
||||
|
||||
```
|
||||
static const char verifyCore[] =
|
||||
"903B291C50C8F0BAB8D2C632853C6D827A9022A4B12260C3A14F4BEBD101228";
|
||||
```
|
||||
|
||||
Replace "903b291C..." with the character sequecece(C66491A040... ) you have stored in your temporary location from above. Save fips_test.c and build the application.
|
||||
|
||||
4. Run the application.
|
||||
|
||||
This time, you should see:
|
||||
|
||||
```
|
||||
Starting Power On Self Test
|
||||
Power On Self Test SUCCESS
|
||||
Waiting for new connection
|
||||
Connection established
|
||||
Received by the secure server: Message number 0
|
||||
|
||||
Received by the secure server: Message number 1
|
||||
|
||||
...
|
||||
|
||||
Received by the secure server: Message number 9
|
||||
|
||||
Connection closed, back to start
|
||||
Waiting for new connection
|
||||
```
|
||||
|
||||
This time, the in-core integrity check and KAT finished successfully, and Demo application was allowed to continue and perform its own tasks.
|
||||
|
||||
# When is the hash value update needed?
|
||||
|
||||
Whenever the FIPS boundary files have had changes made to them, such as options, location in the application, hash value, code, etc. the verifyHash value in fips_test.c will need to be updated. Even you just add or remove your code in your application, it may shift the FIPS boundary code in the memory, thus requiring a new hash value to be computed and updated.
|
@ -1,5 +0,0 @@
|
||||
[InternetShortcut]
|
||||
URL=http://www.freertos.org/FreeRTOS-Plus/WolfSSL/FreeRTOS_WolfSSL_Example.shtml
|
||||
IDList=
|
||||
[{000214A0-0000-0000-C000-000000000046}]
|
||||
Prop3=19,2
|
@ -1,135 +0,0 @@
|
||||
/*
|
||||
* FreeRTOS V202212.00
|
||||
* Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
* this software and associated documentation files (the "Software"), to deal in
|
||||
* the Software without restriction, including without limitation the rights to
|
||||
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||
* the Software, and to permit persons to whom the Software is furnished to do so,
|
||||
* subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* 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 OR
|
||||
* COPYRIGHT HOLDERS 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.
|
||||
*
|
||||
* https://www.FreeRTOS.org
|
||||
* https://github.com/FreeRTOS
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma comment( lib, "ws2_32.lib" )
|
||||
|
||||
/* Win32 includes. */
|
||||
#include <WinSock2.h>
|
||||
|
||||
/* wolfSSL includes. */
|
||||
#include "wolfssl/ssl.h"
|
||||
|
||||
/* Standard includes. */
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
|
||||
/* FreeRTOS includes. */
|
||||
#include "FreeRTOS.h"
|
||||
#include "task.h"
|
||||
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
/* The wolfSSL context for the client. */
|
||||
static WOLFSSL_CTX* xWolfSSL_ClientContext = NULL;
|
||||
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
/* See the comments at the top of main.c. */
|
||||
void vSecureTCPClientTask( void *pvParameters )
|
||||
{
|
||||
SOCKET xClientSocket;
|
||||
struct sockaddr_in xConnection;
|
||||
WOLFSSL* xWolfSSL_Object;
|
||||
WORD wVersionRequested;
|
||||
WSADATA xWSAData;
|
||||
char cString[ 50 ];
|
||||
BaseType_t lReturned;
|
||||
uint32_t ulCount = 0UL;
|
||||
|
||||
/* Remove compiler warning about unused parameters. */
|
||||
( void ) pvParameters;
|
||||
|
||||
/* Prepare to use WinSock. */
|
||||
wVersionRequested = MAKEWORD( 2, 2 );
|
||||
configASSERT( WSAStartup( wVersionRequested, &xWSAData ) == 0 );
|
||||
|
||||
/* Set family and port for client socket. */
|
||||
memset( ( void * ) &xConnection, 0x00, sizeof( struct sockaddr_in ) );
|
||||
xConnection.sin_family = AF_INET;
|
||||
xConnection.sin_addr.s_addr = inet_addr("127.0.0.1");
|
||||
xConnection.sin_port = htons( configTCP_PORT_NUMBER );
|
||||
|
||||
/* Attempt to create a context that uses the TLS 1.3 server protocol. */
|
||||
xWolfSSL_ClientContext = wolfSSL_CTX_new( wolfTLSv1_3_client_method() );
|
||||
configASSERT( xWolfSSL_ClientContext );
|
||||
|
||||
/* Load the CA certificate. */
|
||||
lReturned = wolfSSL_CTX_load_verify_locations( xWolfSSL_ClientContext, "ca-cert.pem", 0 );
|
||||
configASSERT( lReturned == SSL_SUCCESS );
|
||||
|
||||
for( ;; )
|
||||
{
|
||||
/* Create the socket. */
|
||||
xClientSocket = socket( AF_INET, SOCK_STREAM, 0 );
|
||||
configASSERT( xClientSocket != INVALID_SOCKET );
|
||||
|
||||
/* Connect to the secure server. */
|
||||
if( connect( xClientSocket, ( SOCKADDR * ) &xConnection, sizeof( xConnection ) ) == 0 )
|
||||
{
|
||||
/* The connect was successful. Create a wolfSSL object to associate
|
||||
with this connection. */
|
||||
xWolfSSL_Object = wolfSSL_new( xWolfSSL_ClientContext );
|
||||
|
||||
if( xWolfSSL_Object != NULL )
|
||||
{
|
||||
/* Associate the created wolfSSL object with the connected
|
||||
socket. */
|
||||
lReturned = wolfSSL_set_fd( xWolfSSL_Object, xClientSocket );
|
||||
configASSERT( lReturned == SSL_SUCCESS );
|
||||
|
||||
/* The count is used to differentiate between messages sent to
|
||||
the server, and to break out of the do while loop below. */
|
||||
ulCount = 0UL;
|
||||
|
||||
do
|
||||
{
|
||||
/* Create the string that is sent to the secure server. */
|
||||
sprintf( cString, "Message number %lu\r\n", ulCount );
|
||||
|
||||
/* The next line is the secure equivalent of the standard
|
||||
sockets call:
|
||||
lReturned = send( xClientSocket, cString, strlen( cString ) + 1, 0 ); */
|
||||
lReturned = wolfSSL_write( xWolfSSL_Object, cString, strlen( cString ) + 1 );
|
||||
|
||||
|
||||
/* Short delay to prevent the messages streaming up the
|
||||
console too quickly. */
|
||||
vTaskDelay( 50 );
|
||||
ulCount++;
|
||||
|
||||
} while( ( lReturned != SOCKET_ERROR ) && ( ulCount < 10UL ) );
|
||||
}
|
||||
|
||||
wolfSSL_free( xWolfSSL_Object );
|
||||
closesocket( xClientSocket );
|
||||
|
||||
/* Delay for a short time before starting over. */
|
||||
vTaskDelay( 250 );
|
||||
}
|
||||
}
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
@ -1,244 +0,0 @@
|
||||
/*
|
||||
* FreeRTOS V202212.00
|
||||
* Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
* this software and associated documentation files (the "Software"), to deal in
|
||||
* the Software without restriction, including without limitation the rights to
|
||||
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||
* the Software, and to permit persons to whom the Software is furnished to do so,
|
||||
* subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* 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 OR
|
||||
* COPYRIGHT HOLDERS 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.
|
||||
*
|
||||
* https://www.FreeRTOS.org
|
||||
* https://github.com/FreeRTOS
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma comment( lib, "ws2_32.lib" )
|
||||
|
||||
/* Win32 includes. */
|
||||
#include <WinSock2.h>
|
||||
|
||||
/* wolfSSL includes. */
|
||||
#include "wolfssl/ssl.h"
|
||||
|
||||
/* Standard includes. */
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
|
||||
/* FreeRTOS includes. */
|
||||
#include "FreeRTOS.h"
|
||||
#include "task.h"
|
||||
|
||||
/* This application is using the FreeRTOS Windows simulator, which uses the
|
||||
FreeRTOS scheduler to schedule FreeRTOS task within the Windows environment.
|
||||
The Windows envrionment must not be allowed to block any Windows threads that
|
||||
are running FreeRTOS tasks, unless the FreeRTOS task is running at the FreeRTOS
|
||||
idle priority. For simplicity, this demo uses the Windows TCP/IP stack, the
|
||||
API for which can cause Windows threads to block. Therefore, any FreeRTOS task
|
||||
that makes calls to the Windows TCP/IP stack must be assigned the idle prioity.
|
||||
Note this is only a restriction of the simulated Windows environment - real
|
||||
FreeRTOS ports do not have this restriction. */
|
||||
#define sstSECURE_CLIENT_TASK_PRIORITY ( tskIDLE_PRIORITY )
|
||||
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
/*
|
||||
* Open, configures and binds the server's TCP socket.
|
||||
*/
|
||||
static SOCKET prvOpenServerSocket( void );
|
||||
|
||||
/*
|
||||
* Prepare the wolfSSL library for use.
|
||||
*/
|
||||
static void prvInitialiseWolfSSL( void );
|
||||
|
||||
/*
|
||||
* The task that implements the client side of the connection.
|
||||
*/
|
||||
extern void vSecureTCPClientTask( void *pvParameters );
|
||||
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
/* The wolfSSL context for the server. */
|
||||
static WOLFSSL_CTX* xWolfSSL_ServerContext = NULL;
|
||||
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
/* See the comments at the top of main.c. */
|
||||
void vSecureTCPServerTask( void *pvParameters )
|
||||
{
|
||||
BaseType_t xReturned;
|
||||
long lBytes;
|
||||
uint8_t cReceivedString[ 60 ];
|
||||
struct sockaddr_in xClient;
|
||||
int xClientAddressLength = sizeof( struct sockaddr_in );
|
||||
SOCKET xListeningSocket, xConnectedSocket;
|
||||
WOLFSSL* xWolfSSL_Object; /* Only one connection is accepted at a time, so only one object is needed at a time. */
|
||||
|
||||
/* Just to prevent compiler warnings. */
|
||||
( void ) pvParameters;
|
||||
|
||||
/* Perform the initialisation necessary before wolfSSL can be used. */
|
||||
prvInitialiseWolfSSL();
|
||||
configASSERT( xWolfSSL_ServerContext );
|
||||
|
||||
/* Attempt to open the socket. */
|
||||
xListeningSocket = prvOpenServerSocket();
|
||||
|
||||
/* Now the server socket has been created and the wolfSSL library has been
|
||||
initialised, the task that implements the client side can be created. */
|
||||
xTaskCreate( vSecureTCPClientTask, "Client", configMINIMAL_STACK_SIZE, NULL, sstSECURE_CLIENT_TASK_PRIORITY, NULL );
|
||||
|
||||
if( xListeningSocket != INVALID_SOCKET )
|
||||
{
|
||||
for( ;; )
|
||||
{
|
||||
/* Wait until the client connects. */
|
||||
printf( "Waiting for new connection\r\n" );
|
||||
xConnectedSocket = accept( xListeningSocket, ( struct sockaddr * ) &xClient, &xClientAddressLength );
|
||||
|
||||
if( xConnectedSocket != INVALID_SOCKET )
|
||||
{
|
||||
printf( "Connection established\r\n" );
|
||||
|
||||
/* A connection has been accepted by the server. Create a
|
||||
wolfSSL object for use with the newly connected socket. */
|
||||
xWolfSSL_Object = NULL;
|
||||
xWolfSSL_Object = wolfSSL_new( xWolfSSL_ServerContext );
|
||||
|
||||
if( xWolfSSL_Object != NULL )
|
||||
{
|
||||
/* Associate the created wolfSSL object with the connected
|
||||
socket. */
|
||||
xReturned = wolfSSL_set_fd( xWolfSSL_Object, xConnectedSocket );
|
||||
configASSERT( xReturned == SSL_SUCCESS );
|
||||
|
||||
do
|
||||
{
|
||||
/* The next line is the secure equivalent to the
|
||||
standard sockets call:
|
||||
lBytes = recv( xConnectedSocket, cReceivedString, 50, 0 ); */
|
||||
lBytes = wolfSSL_read( xWolfSSL_Object, cReceivedString, sizeof( cReceivedString ) );
|
||||
|
||||
/* Print the received characters. */
|
||||
if( lBytes > 0 )
|
||||
{
|
||||
printf( "Received by the secure server: %s\r\n", cReceivedString );
|
||||
}
|
||||
|
||||
} while ( lBytes > 0 );
|
||||
|
||||
/* The connection was closed, close the socket and free the
|
||||
wolfSSL object. */
|
||||
closesocket( xConnectedSocket );
|
||||
wolfSSL_free( xWolfSSL_Object );
|
||||
printf( "Connection closed, back to start\r\n\r\n" );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
/* The socket could not be opened. */
|
||||
vTaskDelete( NULL );
|
||||
}
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
static SOCKET prvOpenServerSocket( void )
|
||||
{
|
||||
WSADATA xWSAData;
|
||||
WORD wVersionRequested;
|
||||
struct sockaddr_in xConnection;
|
||||
SOCKET xSocket = INVALID_SOCKET;
|
||||
|
||||
wVersionRequested = MAKEWORD( 2, 2 );
|
||||
|
||||
/* Prepare to use WinSock. */
|
||||
if( WSAStartup( wVersionRequested, &xWSAData ) != 0 )
|
||||
{
|
||||
fprintf( stderr, "Could not open Windows connection.\n" );
|
||||
}
|
||||
else
|
||||
{
|
||||
xSocket = socket( AF_INET, SOCK_STREAM, 0 );
|
||||
if( xSocket == INVALID_SOCKET)
|
||||
{
|
||||
fprintf( stderr, "Could not create socket.\n" );
|
||||
WSACleanup();
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Zero out the server structure. */
|
||||
memset( ( void * ) &xConnection, 0x00, sizeof( struct sockaddr_in ) );
|
||||
|
||||
xConnection.sin_family = AF_INET;
|
||||
xConnection.sin_addr.s_addr = inet_addr("127.0.0.1");
|
||||
xConnection.sin_port = htons( configTCP_PORT_NUMBER );
|
||||
|
||||
/* Bind the address to the socket. */
|
||||
if( bind( xSocket, ( struct sockaddr * ) &xConnection, sizeof( struct sockaddr_in ) ) == -1 )
|
||||
{
|
||||
fprintf( stderr, "Could not socket to port %d.\n", configTCP_PORT_NUMBER );
|
||||
closesocket( xSocket );
|
||||
xSocket = INVALID_SOCKET;
|
||||
WSACleanup();
|
||||
}
|
||||
|
||||
if( listen( xSocket, 20 ) != 0 )
|
||||
{
|
||||
closesocket( xSocket );
|
||||
xSocket = INVALID_SOCKET;
|
||||
WSACleanup();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return xSocket;
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
static void prvInitialiseWolfSSL( void )
|
||||
{
|
||||
int32_t iReturn;
|
||||
|
||||
#ifdef DEBUG_WOLFSSL
|
||||
{
|
||||
wolfSSL_Debugging_ON();
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Initialise wolfSSL. This must be done before any other wolfSSL functions
|
||||
are called. */
|
||||
wolfSSL_Init();
|
||||
|
||||
/* Attempt to create a context that uses the TLS 1.3 server protocol. */
|
||||
xWolfSSL_ServerContext = wolfSSL_CTX_new( wolfTLSv1_3_server_method() );
|
||||
|
||||
if( xWolfSSL_ServerContext != NULL )
|
||||
{
|
||||
/* Load the CA certificate. Real applications should ensure that
|
||||
wolfSSL_CTX_load_verify_locations() returns SSL_SUCCESS before
|
||||
proceeding. */
|
||||
iReturn = wolfSSL_CTX_load_verify_locations( xWolfSSL_ServerContext, "ca-cert.pem", 0 );
|
||||
configASSERT( iReturn == SSL_SUCCESS );
|
||||
|
||||
iReturn = wolfSSL_CTX_use_certificate_file( xWolfSSL_ServerContext, "server-cert.pem", SSL_FILETYPE_PEM );
|
||||
configASSERT( iReturn == SSL_SUCCESS );
|
||||
|
||||
iReturn = wolfSSL_CTX_use_PrivateKey_file( xWolfSSL_ServerContext, "server-key.pem", SSL_FILETYPE_PEM );
|
||||
configASSERT( iReturn == SSL_SUCCESS );
|
||||
}
|
||||
}
|
||||
|
@ -1,93 +0,0 @@
|
||||
Certificate:
|
||||
Data:
|
||||
Version: 3 (0x2)
|
||||
Serial Number:
|
||||
5e:ba:a4:f4:b1:f7:48:25:e3:5f:9b:da:a1:13:ed:d5:2b:03:67:15
|
||||
Signature Algorithm: sha256WithRSAEncryption
|
||||
Issuer: C = US, ST = Montana, L = Bozeman, O = Sawtooth, OU = Consulting, CN = www.wolfssl.com, emailAddress = info@wolfssl.com
|
||||
Validity
|
||||
Not Before: Jun 19 13:23:41 2020 GMT
|
||||
Not After : Mar 16 13:23:41 2023 GMT
|
||||
Subject: C = US, ST = Montana, L = Bozeman, O = Sawtooth, OU = Consulting, CN = www.wolfssl.com, emailAddress = info@wolfssl.com
|
||||
Subject Public Key Info:
|
||||
Public Key Algorithm: rsaEncryption
|
||||
RSA Public-Key: (2048 bit)
|
||||
Modulus:
|
||||
00:bf:0c:ca:2d:14:b2:1e:84:42:5b:cd:38:1f:4a:
|
||||
f2:4d:75:10:f1:b6:35:9f:df:ca:7d:03:98:d3:ac:
|
||||
de:03:66:ee:2a:f1:d8:b0:7d:6e:07:54:0b:10:98:
|
||||
21:4d:80:cb:12:20:e7:cc:4f:de:45:7d:c9:72:77:
|
||||
32:ea:ca:90:bb:69:52:10:03:2f:a8:f3:95:c5:f1:
|
||||
8b:62:56:1b:ef:67:6f:a4:10:41:95:ad:0a:9b:e3:
|
||||
a5:c0:b0:d2:70:76:50:30:5b:a8:e8:08:2c:7c:ed:
|
||||
a7:a2:7a:8d:38:29:1c:ac:c7:ed:f2:7c:95:b0:95:
|
||||
82:7d:49:5c:38:cd:77:25:ef:bd:80:75:53:94:3c:
|
||||
3d:ca:63:5b:9f:15:b5:d3:1d:13:2f:19:d1:3c:db:
|
||||
76:3a:cc:b8:7d:c9:e5:c2:d7:da:40:6f:d8:21:dc:
|
||||
73:1b:42:2d:53:9c:fe:1a:fc:7d:ab:7a:36:3f:98:
|
||||
de:84:7c:05:67:ce:6a:14:38:87:a9:f1:8c:b5:68:
|
||||
cb:68:7f:71:20:2b:f5:a0:63:f5:56:2f:a3:26:d2:
|
||||
b7:6f:b1:5a:17:d7:38:99:08:fe:93:58:6f:fe:c3:
|
||||
13:49:08:16:0b:a7:4d:67:00:52:31:67:23:4e:98:
|
||||
ed:51:45:1d:b9:04:d9:0b:ec:d8:28:b3:4b:bd:ed:
|
||||
36:79
|
||||
Exponent: 65537 (0x10001)
|
||||
X509v3 extensions:
|
||||
X509v3 Subject Key Identifier:
|
||||
27:8E:67:11:74:C3:26:1D:3F:ED:33:63:B3:A4:D8:1D:30:E5:E8:D5
|
||||
X509v3 Authority Key Identifier:
|
||||
keyid:27:8E:67:11:74:C3:26:1D:3F:ED:33:63:B3:A4:D8:1D:30:E5:E8:D5
|
||||
DirName:/C=US/ST=Montana/L=Bozeman/O=Sawtooth/OU=Consulting/CN=www.wolfssl.com/emailAddress=info@wolfssl.com
|
||||
serial:5E:BA:A4:F4:B1:F7:48:25:E3:5F:9B:DA:A1:13:ED:D5:2B:03:67:15
|
||||
|
||||
X509v3 Basic Constraints:
|
||||
CA:TRUE
|
||||
X509v3 Subject Alternative Name:
|
||||
DNS:example.com, IP Address:127.0.0.1
|
||||
X509v3 Extended Key Usage:
|
||||
TLS Web Server Authentication, TLS Web Client Authentication
|
||||
Signature Algorithm: sha256WithRSAEncryption
|
||||
b9:ed:94:3e:00:73:2d:a5:d1:04:b3:fb:dc:f0:b7:0d:3d:ad:
|
||||
96:74:4c:92:67:ad:6d:7c:e2:99:6a:33:ca:b2:0f:04:5a:a5:
|
||||
67:f8:e3:0b:3d:f5:d0:5b:1e:20:52:12:92:28:ea:31:a3:51:
|
||||
9e:8b:d2:39:e4:25:ea:61:61:41:16:2d:54:50:d3:fb:d0:34:
|
||||
00:10:f1:7b:bc:f0:08:a7:f5:27:5e:7e:40:9d:99:b0:d3:31:
|
||||
11:c3:9d:a9:51:a0:17:cf:83:2c:55:84:e0:d5:92:a0:05:3a:
|
||||
9f:b8:75:f8:1b:e5:f7:a4:6c:e9:aa:25:8b:19:93:46:1f:3f:
|
||||
33:af:47:29:cf:7b:8b:59:27:eb:d7:4f:cb:33:19:fa:5f:ee:
|
||||
d8:13:e9:0c:07:ad:3b:c0:7f:10:d7:e4:ed:e8:db:16:e1:1f:
|
||||
a4:7f:16:3c:bd:d7:11:f2:d4:3a:a9:9b:95:e1:39:51:99:eb:
|
||||
5b:65:46:ef:63:84:73:95:23:b8:bf:b5:f6:4d:12:71:f7:ff:
|
||||
33:aa:4a:8c:65:73:73:89:69:df:a6:dc:a4:91:ff:ae:c7:28:
|
||||
93:b5:1a:de:a9:8f:2b:30:85:83:8b:99:82:ca:b3:7c:11:10:
|
||||
88:9d:8e:6c:2c:f3:05:6f:cb:80:85:16:b7:ed:e4:68:fb:b6:
|
||||
b6:31:8a:7d
|
||||
-----BEGIN CERTIFICATE-----
|
||||
MIIE/zCCA+egAwIBAgIUXrqk9LH3SCXjX5vaoRPt1SsDZxUwDQYJKoZIhvcNAQEL
|
||||
BQAwgZQxCzAJBgNVBAYTAlVTMRAwDgYDVQQIDAdNb250YW5hMRAwDgYDVQQHDAdC
|
||||
b3plbWFuMREwDwYDVQQKDAhTYXd0b290aDETMBEGA1UECwwKQ29uc3VsdGluZzEY
|
||||
MBYGA1UEAwwPd3d3LndvbGZzc2wuY29tMR8wHQYJKoZIhvcNAQkBFhBpbmZvQHdv
|
||||
bGZzc2wuY29tMB4XDTIwMDYxOTEzMjM0MVoXDTIzMDMxNjEzMjM0MVowgZQxCzAJ
|
||||
BgNVBAYTAlVTMRAwDgYDVQQIDAdNb250YW5hMRAwDgYDVQQHDAdCb3plbWFuMREw
|
||||
DwYDVQQKDAhTYXd0b290aDETMBEGA1UECwwKQ29uc3VsdGluZzEYMBYGA1UEAwwP
|
||||
d3d3LndvbGZzc2wuY29tMR8wHQYJKoZIhvcNAQkBFhBpbmZvQHdvbGZzc2wuY29t
|
||||
MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAvwzKLRSyHoRCW804H0ry
|
||||
TXUQ8bY1n9/KfQOY06zeA2buKvHYsH1uB1QLEJghTYDLEiDnzE/eRX3Jcncy6sqQ
|
||||
u2lSEAMvqPOVxfGLYlYb72dvpBBBla0Km+OlwLDScHZQMFuo6AgsfO2nonqNOCkc
|
||||
rMft8nyVsJWCfUlcOM13Je+9gHVTlDw9ymNbnxW10x0TLxnRPNt2Osy4fcnlwtfa
|
||||
QG/YIdxzG0ItU5z+Gvx9q3o2P5jehHwFZ85qFDiHqfGMtWjLaH9xICv1oGP1Vi+j
|
||||
JtK3b7FaF9c4mQj+k1hv/sMTSQgWC6dNZwBSMWcjTpjtUUUduQTZC+zYKLNLve02
|
||||
eQIDAQABo4IBRTCCAUEwHQYDVR0OBBYEFCeOZxF0wyYdP+0zY7Ok2B0w5ejVMIHU
|
||||
BgNVHSMEgcwwgcmAFCeOZxF0wyYdP+0zY7Ok2B0w5ejVoYGapIGXMIGUMQswCQYD
|
||||
VQQGEwJVUzEQMA4GA1UECAwHTW9udGFuYTEQMA4GA1UEBwwHQm96ZW1hbjERMA8G
|
||||
A1UECgwIU2F3dG9vdGgxEzARBgNVBAsMCkNvbnN1bHRpbmcxGDAWBgNVBAMMD3d3
|
||||
dy53b2xmc3NsLmNvbTEfMB0GCSqGSIb3DQEJARYQaW5mb0B3b2xmc3NsLmNvbYIU
|
||||
Xrqk9LH3SCXjX5vaoRPt1SsDZxUwDAYDVR0TBAUwAwEB/zAcBgNVHREEFTATggtl
|
||||
eGFtcGxlLmNvbYcEfwAAATAdBgNVHSUEFjAUBggrBgEFBQcDAQYIKwYBBQUHAwIw
|
||||
DQYJKoZIhvcNAQELBQADggEBALntlD4Acy2l0QSz+9zwtw09rZZ0TJJnrW184plq
|
||||
M8qyDwRapWf44ws99dBbHiBSEpIo6jGjUZ6L0jnkJephYUEWLVRQ0/vQNAAQ8Xu8
|
||||
8Ain9SdefkCdmbDTMRHDnalRoBfPgyxVhODVkqAFOp+4dfgb5fekbOmqJYsZk0Yf
|
||||
PzOvRynPe4tZJ+vXT8szGfpf7tgT6QwHrTvAfxDX5O3o2xbhH6R/Fjy91xHy1Dqp
|
||||
m5XhOVGZ61tlRu9jhHOVI7i/tfZNEnH3/zOqSoxlc3OJad+m3KSR/67HKJO1Gt6p
|
||||
jyswhYOLmYLKs3wREIidjmws8wVvy4CFFrft5Gj7trYxin0=
|
||||
-----END CERTIFICATE-----
|
@ -1,95 +0,0 @@
|
||||
/*
|
||||
* FreeRTOS V202212.00
|
||||
* Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
* this software and associated documentation files (the "Software"), to deal in
|
||||
* the Software without restriction, including without limitation the rights to
|
||||
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||
* the Software, and to permit persons to whom the Software is furnished to do so,
|
||||
* subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* 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 OR
|
||||
* COPYRIGHT HOLDERS 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.
|
||||
*
|
||||
* https://www.FreeRTOS.org
|
||||
* https://github.com/FreeRTOS
|
||||
*
|
||||
*/
|
||||
|
||||
/* Standard includes. */
|
||||
#include <stdio.h>
|
||||
#include <stdint.h>
|
||||
|
||||
/* FreeRTOS includes. */
|
||||
#include <FreeRTOS.h>
|
||||
#include "task.h"
|
||||
|
||||
/* This application is using the FreeRTOS Windows simulator, which uses the
|
||||
FreeRTOS scheduler to schedule FreeRTOS task within the Windows environment.
|
||||
The Windows environment must not be allowed to block any Windows threads that
|
||||
are running FreeRTOS tasks, unless the FreeRTOS task is running at the FreeRTOS
|
||||
idle priority. For simplicity, this demo uses the Windows TCP/IP stack, the
|
||||
API for which can cause Windows threads to block. Therefore, any FreeRTOS task
|
||||
that makes calls to the Windows TCP/IP stack must be assigned the idle priority.
|
||||
Note this is only a restriction of the simulated Windows environment - real
|
||||
FreeRTOS ports do not have this restriction. */
|
||||
#define mainSECURE_SERVER_TASK_PRIORITY ( tskIDLE_PRIORITY )
|
||||
|
||||
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
/*
|
||||
* The task that implements the server side.
|
||||
*/
|
||||
extern void vSecureTCPServerTask( void *pvParameters );
|
||||
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
/*
|
||||
*! It is necessary to update the build hash before running this project for the
|
||||
*! time. Ensure to read README_wolfSSL_FIPS_ready.md in the directory that contains
|
||||
*! this Visual Studio project for instructions.
|
||||
*/
|
||||
int main( void )
|
||||
{
|
||||
const uint32_t ulLongTime_ms = 250UL;
|
||||
|
||||
/* Create the TCP server task. This will itself create the client task
|
||||
once it has completed the wolfSSL initialisation. */
|
||||
xTaskCreate( vSecureTCPServerTask, "Server", configMINIMAL_STACK_SIZE, NULL, mainSECURE_SERVER_TASK_PRIORITY, NULL );
|
||||
|
||||
/* Start the task running. */
|
||||
vTaskStartScheduler();
|
||||
|
||||
/* If all is well, the scheduler will now be running, and the following
|
||||
line will never be reached. If the following line does execute, then
|
||||
there was insufficient FreeRTOS heap memory available for the idle and/or
|
||||
timer tasks to be created. See the memory management section on the
|
||||
FreeRTOS web site for more details (this is standard text that is not
|
||||
really applicable to the Win32 simulator port). */
|
||||
for( ;; )
|
||||
{
|
||||
Sleep( ulLongTime_ms );
|
||||
}
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
void vApplicationIdleHook( void )
|
||||
{
|
||||
const unsigned long ulMSToSleep = 5;
|
||||
|
||||
/* This function is called on each cycle of the idle task if
|
||||
configUSE_IDLE_HOOK is set to 1 in FreeRTOSConfig.h. Sleep to reduce CPU
|
||||
load. */
|
||||
Sleep( ulMSToSleep );
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
@ -1,185 +0,0 @@
|
||||
Certificate:
|
||||
Data:
|
||||
Version: 3 (0x2)
|
||||
Serial Number: 1 (0x1)
|
||||
Signature Algorithm: sha256WithRSAEncryption
|
||||
Issuer: C = US, ST = Montana, L = Bozeman, O = Sawtooth, OU = Consulting, CN = www.wolfssl.com, emailAddress = info@wolfssl.com
|
||||
Validity
|
||||
Not Before: Jun 19 13:23:41 2020 GMT
|
||||
Not After : Mar 16 13:23:41 2023 GMT
|
||||
Subject: C = US, ST = Montana, L = Bozeman, O = wolfSSL, OU = Support, CN = www.wolfssl.com, emailAddress = info@wolfssl.com
|
||||
Subject Public Key Info:
|
||||
Public Key Algorithm: rsaEncryption
|
||||
RSA Public-Key: (2048 bit)
|
||||
Modulus:
|
||||
00:c0:95:08:e1:57:41:f2:71:6d:b7:d2:45:41:27:
|
||||
01:65:c6:45:ae:f2:bc:24:30:b8:95:ce:2f:4e:d6:
|
||||
f6:1c:88:bc:7c:9f:fb:a8:67:7f:fe:5c:9c:51:75:
|
||||
f7:8a:ca:07:e7:35:2f:8f:e1:bd:7b:c0:2f:7c:ab:
|
||||
64:a8:17:fc:ca:5d:7b:ba:e0:21:e5:72:2e:6f:2e:
|
||||
86:d8:95:73:da:ac:1b:53:b9:5f:3f:d7:19:0d:25:
|
||||
4f:e1:63:63:51:8b:0b:64:3f:ad:43:b8:a5:1c:5c:
|
||||
34:b3:ae:00:a0:63:c5:f6:7f:0b:59:68:78:73:a6:
|
||||
8c:18:a9:02:6d:af:c3:19:01:2e:b8:10:e3:c6:cc:
|
||||
40:b4:69:a3:46:33:69:87:6e:c4:bb:17:a6:f3:e8:
|
||||
dd:ad:73:bc:7b:2f:21:b5:fd:66:51:0c:bd:54:b3:
|
||||
e1:6d:5f:1c:bc:23:73:d1:09:03:89:14:d2:10:b9:
|
||||
64:c3:2a:d0:a1:96:4a:bc:e1:d4:1a:5b:c7:a0:c0:
|
||||
c1:63:78:0f:44:37:30:32:96:80:32:23:95:a1:77:
|
||||
ba:13:d2:97:73:e2:5d:25:c9:6a:0d:c3:39:60:a4:
|
||||
b4:b0:69:42:42:09:e9:d8:08:bc:33:20:b3:58:22:
|
||||
a7:aa:eb:c4:e1:e6:61:83:c5:d2:96:df:d9:d0:4f:
|
||||
ad:d7
|
||||
Exponent: 65537 (0x10001)
|
||||
X509v3 extensions:
|
||||
X509v3 Subject Key Identifier:
|
||||
B3:11:32:C9:92:98:84:E2:C9:F8:D0:3B:6E:03:42:CA:1F:0E:8E:3C
|
||||
X509v3 Authority Key Identifier:
|
||||
keyid:27:8E:67:11:74:C3:26:1D:3F:ED:33:63:B3:A4:D8:1D:30:E5:E8:D5
|
||||
DirName:/C=US/ST=Montana/L=Bozeman/O=Sawtooth/OU=Consulting/CN=www.wolfssl.com/emailAddress=info@wolfssl.com
|
||||
serial:5E:BA:A4:F4:B1:F7:48:25:E3:5F:9B:DA:A1:13:ED:D5:2B:03:67:15
|
||||
|
||||
X509v3 Basic Constraints:
|
||||
CA:TRUE
|
||||
X509v3 Subject Alternative Name:
|
||||
DNS:example.com, IP Address:127.0.0.1
|
||||
X509v3 Extended Key Usage:
|
||||
TLS Web Server Authentication, TLS Web Client Authentication
|
||||
Signature Algorithm: sha256WithRSAEncryption
|
||||
35:91:e6:72:cc:0b:f1:47:8f:3d:e3:5d:52:2f:83:b8:b1:3b:
|
||||
6d:d6:ac:13:79:74:14:ff:07:8d:ee:74:77:64:ff:b8:83:1d:
|
||||
81:80:84:bb:38:fa:8f:f3:75:29:23:ce:e5:09:a8:13:85:14:
|
||||
b6:6a:35:30:2c:1c:c4:0f:23:67:ea:ed:cb:91:c4:05:e3:ec:
|
||||
6b:be:11:bf:d9:9a:ab:93:17:9f:e4:9a:59:d4:e7:cc:ce:dc:
|
||||
83:10:f5:cd:de:d7:35:75:4b:aa:7a:7a:ba:02:a0:b0:b5:c1:
|
||||
8a:6b:b1:72:cf:64:59:4e:d3:a4:a1:6c:64:4b:14:cf:a3:d6:
|
||||
37:0a:e6:f9:5b:21:be:de:0c:c1:cf:43:e1:18:0b:19:13:6b:
|
||||
8e:3d:df:0f:a7:43:fb:35:67:4a:50:e8:09:46:34:bd:f4:ab:
|
||||
1a:8f:bd:4d:1c:6b:20:be:1c:8c:ca:66:98:ba:03:67:f2:1c:
|
||||
3c:1e:01:f0:4d:c6:85:82:6f:a9:49:f7:1b:7d:6b:db:76:84:
|
||||
73:bb:16:c5:6e:74:ab:7b:fb:1c:e9:91:bb:29:73:1c:de:27:
|
||||
b4:67:3b:10:51:f4:17:eb:b8:38:a0:9a:eb:37:5b:76:8f:39:
|
||||
12:39:35:d1:ca:fe:c0:26:fb:73:50:1e:2d:b9:d2:ba:e5:4c:
|
||||
35:bd:ed:7b
|
||||
-----BEGIN CERTIFICATE-----
|
||||
MIIE6DCCA9CgAwIBAgIBATANBgkqhkiG9w0BAQsFADCBlDELMAkGA1UEBhMCVVMx
|
||||
EDAOBgNVBAgMB01vbnRhbmExEDAOBgNVBAcMB0JvemVtYW4xETAPBgNVBAoMCFNh
|
||||
d3Rvb3RoMRMwEQYDVQQLDApDb25zdWx0aW5nMRgwFgYDVQQDDA93d3cud29sZnNz
|
||||
bC5jb20xHzAdBgkqhkiG9w0BCQEWEGluZm9Ad29sZnNzbC5jb20wHhcNMjAwNjE5
|
||||
MTMyMzQxWhcNMjMwMzE2MTMyMzQxWjCBkDELMAkGA1UEBhMCVVMxEDAOBgNVBAgM
|
||||
B01vbnRhbmExEDAOBgNVBAcMB0JvemVtYW4xEDAOBgNVBAoMB3dvbGZTU0wxEDAO
|
||||
BgNVBAsMB1N1cHBvcnQxGDAWBgNVBAMMD3d3dy53b2xmc3NsLmNvbTEfMB0GCSqG
|
||||
SIb3DQEJARYQaW5mb0B3b2xmc3NsLmNvbTCCASIwDQYJKoZIhvcNAQEBBQADggEP
|
||||
ADCCAQoCggEBAMCVCOFXQfJxbbfSRUEnAWXGRa7yvCQwuJXOL07W9hyIvHyf+6hn
|
||||
f/5cnFF194rKB+c1L4/hvXvAL3yrZKgX/Mpde7rgIeVyLm8uhtiVc9qsG1O5Xz/X
|
||||
GQ0lT+FjY1GLC2Q/rUO4pRxcNLOuAKBjxfZ/C1loeHOmjBipAm2vwxkBLrgQ48bM
|
||||
QLRpo0YzaYduxLsXpvPo3a1zvHsvIbX9ZlEMvVSz4W1fHLwjc9EJA4kU0hC5ZMMq
|
||||
0KGWSrzh1Bpbx6DAwWN4D0Q3MDKWgDIjlaF3uhPSl3PiXSXJag3DOWCktLBpQkIJ
|
||||
6dgIvDMgs1gip6rrxOHmYYPF0pbf2dBPrdcCAwEAAaOCAUUwggFBMB0GA1UdDgQW
|
||||
BBSzETLJkpiE4sn40DtuA0LKHw6OPDCB1AYDVR0jBIHMMIHJgBQnjmcRdMMmHT/t
|
||||
M2OzpNgdMOXo1aGBmqSBlzCBlDELMAkGA1UEBhMCVVMxEDAOBgNVBAgMB01vbnRh
|
||||
bmExEDAOBgNVBAcMB0JvemVtYW4xETAPBgNVBAoMCFNhd3Rvb3RoMRMwEQYDVQQL
|
||||
DApDb25zdWx0aW5nMRgwFgYDVQQDDA93d3cud29sZnNzbC5jb20xHzAdBgkqhkiG
|
||||
9w0BCQEWEGluZm9Ad29sZnNzbC5jb22CFF66pPSx90gl41+b2qET7dUrA2cVMAwG
|
||||
A1UdEwQFMAMBAf8wHAYDVR0RBBUwE4ILZXhhbXBsZS5jb22HBH8AAAEwHQYDVR0l
|
||||
BBYwFAYIKwYBBQUHAwEGCCsGAQUFBwMCMA0GCSqGSIb3DQEBCwUAA4IBAQA1keZy
|
||||
zAvxR489411SL4O4sTtt1qwTeXQU/weN7nR3ZP+4gx2BgIS7OPqP83UpI87lCagT
|
||||
hRS2ajUwLBzEDyNn6u3LkcQF4+xrvhG/2Zqrkxef5JpZ1OfMztyDEPXN3tc1dUuq
|
||||
enq6AqCwtcGKa7Fyz2RZTtOkoWxkSxTPo9Y3Cub5WyG+3gzBz0PhGAsZE2uOPd8P
|
||||
p0P7NWdKUOgJRjS99Ksaj71NHGsgvhyMymaYugNn8hw8HgHwTcaFgm+pSfcbfWvb
|
||||
doRzuxbFbnSre/sc6ZG7KXMc3ie0ZzsQUfQX67g4oJrrN1t2jzkSOTXRyv7AJvtz
|
||||
UB4tudK65Uw1ve17
|
||||
-----END CERTIFICATE-----
|
||||
Certificate:
|
||||
Data:
|
||||
Version: 3 (0x2)
|
||||
Serial Number:
|
||||
5e:ba:a4:f4:b1:f7:48:25:e3:5f:9b:da:a1:13:ed:d5:2b:03:67:15
|
||||
Signature Algorithm: sha256WithRSAEncryption
|
||||
Issuer: C = US, ST = Montana, L = Bozeman, O = Sawtooth, OU = Consulting, CN = www.wolfssl.com, emailAddress = info@wolfssl.com
|
||||
Validity
|
||||
Not Before: Jun 19 13:23:41 2020 GMT
|
||||
Not After : Mar 16 13:23:41 2023 GMT
|
||||
Subject: C = US, ST = Montana, L = Bozeman, O = Sawtooth, OU = Consulting, CN = www.wolfssl.com, emailAddress = info@wolfssl.com
|
||||
Subject Public Key Info:
|
||||
Public Key Algorithm: rsaEncryption
|
||||
RSA Public-Key: (2048 bit)
|
||||
Modulus:
|
||||
00:bf:0c:ca:2d:14:b2:1e:84:42:5b:cd:38:1f:4a:
|
||||
f2:4d:75:10:f1:b6:35:9f:df:ca:7d:03:98:d3:ac:
|
||||
de:03:66:ee:2a:f1:d8:b0:7d:6e:07:54:0b:10:98:
|
||||
21:4d:80:cb:12:20:e7:cc:4f:de:45:7d:c9:72:77:
|
||||
32:ea:ca:90:bb:69:52:10:03:2f:a8:f3:95:c5:f1:
|
||||
8b:62:56:1b:ef:67:6f:a4:10:41:95:ad:0a:9b:e3:
|
||||
a5:c0:b0:d2:70:76:50:30:5b:a8:e8:08:2c:7c:ed:
|
||||
a7:a2:7a:8d:38:29:1c:ac:c7:ed:f2:7c:95:b0:95:
|
||||
82:7d:49:5c:38:cd:77:25:ef:bd:80:75:53:94:3c:
|
||||
3d:ca:63:5b:9f:15:b5:d3:1d:13:2f:19:d1:3c:db:
|
||||
76:3a:cc:b8:7d:c9:e5:c2:d7:da:40:6f:d8:21:dc:
|
||||
73:1b:42:2d:53:9c:fe:1a:fc:7d:ab:7a:36:3f:98:
|
||||
de:84:7c:05:67:ce:6a:14:38:87:a9:f1:8c:b5:68:
|
||||
cb:68:7f:71:20:2b:f5:a0:63:f5:56:2f:a3:26:d2:
|
||||
b7:6f:b1:5a:17:d7:38:99:08:fe:93:58:6f:fe:c3:
|
||||
13:49:08:16:0b:a7:4d:67:00:52:31:67:23:4e:98:
|
||||
ed:51:45:1d:b9:04:d9:0b:ec:d8:28:b3:4b:bd:ed:
|
||||
36:79
|
||||
Exponent: 65537 (0x10001)
|
||||
X509v3 extensions:
|
||||
X509v3 Subject Key Identifier:
|
||||
27:8E:67:11:74:C3:26:1D:3F:ED:33:63:B3:A4:D8:1D:30:E5:E8:D5
|
||||
X509v3 Authority Key Identifier:
|
||||
keyid:27:8E:67:11:74:C3:26:1D:3F:ED:33:63:B3:A4:D8:1D:30:E5:E8:D5
|
||||
DirName:/C=US/ST=Montana/L=Bozeman/O=Sawtooth/OU=Consulting/CN=www.wolfssl.com/emailAddress=info@wolfssl.com
|
||||
serial:5E:BA:A4:F4:B1:F7:48:25:E3:5F:9B:DA:A1:13:ED:D5:2B:03:67:15
|
||||
|
||||
X509v3 Basic Constraints:
|
||||
CA:TRUE
|
||||
X509v3 Subject Alternative Name:
|
||||
DNS:example.com, IP Address:127.0.0.1
|
||||
X509v3 Extended Key Usage:
|
||||
TLS Web Server Authentication, TLS Web Client Authentication
|
||||
Signature Algorithm: sha256WithRSAEncryption
|
||||
b9:ed:94:3e:00:73:2d:a5:d1:04:b3:fb:dc:f0:b7:0d:3d:ad:
|
||||
96:74:4c:92:67:ad:6d:7c:e2:99:6a:33:ca:b2:0f:04:5a:a5:
|
||||
67:f8:e3:0b:3d:f5:d0:5b:1e:20:52:12:92:28:ea:31:a3:51:
|
||||
9e:8b:d2:39:e4:25:ea:61:61:41:16:2d:54:50:d3:fb:d0:34:
|
||||
00:10:f1:7b:bc:f0:08:a7:f5:27:5e:7e:40:9d:99:b0:d3:31:
|
||||
11:c3:9d:a9:51:a0:17:cf:83:2c:55:84:e0:d5:92:a0:05:3a:
|
||||
9f:b8:75:f8:1b:e5:f7:a4:6c:e9:aa:25:8b:19:93:46:1f:3f:
|
||||
33:af:47:29:cf:7b:8b:59:27:eb:d7:4f:cb:33:19:fa:5f:ee:
|
||||
d8:13:e9:0c:07:ad:3b:c0:7f:10:d7:e4:ed:e8:db:16:e1:1f:
|
||||
a4:7f:16:3c:bd:d7:11:f2:d4:3a:a9:9b:95:e1:39:51:99:eb:
|
||||
5b:65:46:ef:63:84:73:95:23:b8:bf:b5:f6:4d:12:71:f7:ff:
|
||||
33:aa:4a:8c:65:73:73:89:69:df:a6:dc:a4:91:ff:ae:c7:28:
|
||||
93:b5:1a:de:a9:8f:2b:30:85:83:8b:99:82:ca:b3:7c:11:10:
|
||||
88:9d:8e:6c:2c:f3:05:6f:cb:80:85:16:b7:ed:e4:68:fb:b6:
|
||||
b6:31:8a:7d
|
||||
-----BEGIN CERTIFICATE-----
|
||||
MIIE/zCCA+egAwIBAgIUXrqk9LH3SCXjX5vaoRPt1SsDZxUwDQYJKoZIhvcNAQEL
|
||||
BQAwgZQxCzAJBgNVBAYTAlVTMRAwDgYDVQQIDAdNb250YW5hMRAwDgYDVQQHDAdC
|
||||
b3plbWFuMREwDwYDVQQKDAhTYXd0b290aDETMBEGA1UECwwKQ29uc3VsdGluZzEY
|
||||
MBYGA1UEAwwPd3d3LndvbGZzc2wuY29tMR8wHQYJKoZIhvcNAQkBFhBpbmZvQHdv
|
||||
bGZzc2wuY29tMB4XDTIwMDYxOTEzMjM0MVoXDTIzMDMxNjEzMjM0MVowgZQxCzAJ
|
||||
BgNVBAYTAlVTMRAwDgYDVQQIDAdNb250YW5hMRAwDgYDVQQHDAdCb3plbWFuMREw
|
||||
DwYDVQQKDAhTYXd0b290aDETMBEGA1UECwwKQ29uc3VsdGluZzEYMBYGA1UEAwwP
|
||||
d3d3LndvbGZzc2wuY29tMR8wHQYJKoZIhvcNAQkBFhBpbmZvQHdvbGZzc2wuY29t
|
||||
MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAvwzKLRSyHoRCW804H0ry
|
||||
TXUQ8bY1n9/KfQOY06zeA2buKvHYsH1uB1QLEJghTYDLEiDnzE/eRX3Jcncy6sqQ
|
||||
u2lSEAMvqPOVxfGLYlYb72dvpBBBla0Km+OlwLDScHZQMFuo6AgsfO2nonqNOCkc
|
||||
rMft8nyVsJWCfUlcOM13Je+9gHVTlDw9ymNbnxW10x0TLxnRPNt2Osy4fcnlwtfa
|
||||
QG/YIdxzG0ItU5z+Gvx9q3o2P5jehHwFZ85qFDiHqfGMtWjLaH9xICv1oGP1Vi+j
|
||||
JtK3b7FaF9c4mQj+k1hv/sMTSQgWC6dNZwBSMWcjTpjtUUUduQTZC+zYKLNLve02
|
||||
eQIDAQABo4IBRTCCAUEwHQYDVR0OBBYEFCeOZxF0wyYdP+0zY7Ok2B0w5ejVMIHU
|
||||
BgNVHSMEgcwwgcmAFCeOZxF0wyYdP+0zY7Ok2B0w5ejVoYGapIGXMIGUMQswCQYD
|
||||
VQQGEwJVUzEQMA4GA1UECAwHTW9udGFuYTEQMA4GA1UEBwwHQm96ZW1hbjERMA8G
|
||||
A1UECgwIU2F3dG9vdGgxEzARBgNVBAsMCkNvbnN1bHRpbmcxGDAWBgNVBAMMD3d3
|
||||
dy53b2xmc3NsLmNvbTEfMB0GCSqGSIb3DQEJARYQaW5mb0B3b2xmc3NsLmNvbYIU
|
||||
Xrqk9LH3SCXjX5vaoRPt1SsDZxUwDAYDVR0TBAUwAwEB/zAcBgNVHREEFTATggtl
|
||||
eGFtcGxlLmNvbYcEfwAAATAdBgNVHSUEFjAUBggrBgEFBQcDAQYIKwYBBQUHAwIw
|
||||
DQYJKoZIhvcNAQELBQADggEBALntlD4Acy2l0QSz+9zwtw09rZZ0TJJnrW184plq
|
||||
M8qyDwRapWf44ws99dBbHiBSEpIo6jGjUZ6L0jnkJephYUEWLVRQ0/vQNAAQ8Xu8
|
||||
8Ain9SdefkCdmbDTMRHDnalRoBfPgyxVhODVkqAFOp+4dfgb5fekbOmqJYsZk0Yf
|
||||
PzOvRynPe4tZJ+vXT8szGfpf7tgT6QwHrTvAfxDX5O3o2xbhH6R/Fjy91xHy1Dqp
|
||||
m5XhOVGZ61tlRu9jhHOVI7i/tfZNEnH3/zOqSoxlc3OJad+m3KSR/67HKJO1Gt6p
|
||||
jyswhYOLmYLKs3wREIidjmws8wVvy4CFFrft5Gj7trYxin0=
|
||||
-----END CERTIFICATE-----
|
@ -1,27 +0,0 @@
|
||||
-----BEGIN RSA PRIVATE KEY-----
|
||||
MIIEpQIBAAKCAQEAwJUI4VdB8nFtt9JFQScBZcZFrvK8JDC4lc4vTtb2HIi8fJ/7
|
||||
qGd//lycUXX3isoH5zUvj+G9e8AvfKtkqBf8yl17uuAh5XIuby6G2JVz2qwbU7lf
|
||||
P9cZDSVP4WNjUYsLZD+tQ7ilHFw0s64AoGPF9n8LWWh4c6aMGKkCba/DGQEuuBDj
|
||||
xsxAtGmjRjNph27Euxem8+jdrXO8ey8htf1mUQy9VLPhbV8cvCNz0QkDiRTSELlk
|
||||
wyrQoZZKvOHUGlvHoMDBY3gPRDcwMpaAMiOVoXe6E9KXc+JdJclqDcM5YKS0sGlC
|
||||
Qgnp2Ai8MyCzWCKnquvE4eZhg8XSlt/Z0E+t1wIDAQABAoIBAQCa0DQPUmIFUAHv
|
||||
n+1kbsLE2hryhNeSEEiSxOlq64t1bMZ5OPLJckqGZFSVd8vDmp231B2kAMieTuTd
|
||||
x7pnFsF0vKnWlI8rMBr77d8hBSPZSjm9mGtlmrjcxH3upkMVLj2+HSJgKnMw1T7Y
|
||||
oqyGQy7E9WReP4l1DxHYUSVOn9iqo85gs+KK2X4b8GTKmlsFC1uqy+XjP24yIgXz
|
||||
0PrvdFKB4l90073/MYNFdfpjepcu1rYZxpIm5CgGUFAOeC6peA0Ul7QS2DFAq6EB
|
||||
QcIw+AdfFuRhd9Jg8p+N6PS662PeKpeB70xs5lU0USsoNPRTHMRYCj+7r7X3SoVD
|
||||
LTzxWFiBAoGBAPIsVHY5I2PJEDK3k62vvhl1loFk5rW4iUJB0W3QHBv4G6xpyzY8
|
||||
ZH3c9Bm4w2CxV0hfUk9ZOlV/MsAZQ1A/rs5vF/MOn0DKTq0VO8l56cBZOHNwnAp8
|
||||
yTpIMqfYSXUKhcLC/RVz2pkJKmmanwpxv7AEpox6Wm9IWlQ7xrFTF9/nAoGBAMuT
|
||||
3ncVXbdcXHzYkKmYLdZpDmOzo9ymzItqpKISjI57SCyySzfcBhh96v52odSh6T8N
|
||||
zRtfr1+elltbD6F8r7ObkNtXczrtsCNErkFPHwdCEyNMy/r0FKTV9542fFufqDzB
|
||||
hV900jkt/9CE3/uzIHoumxeu5roLrl9TpFLtG8SRAoGBAOyY2rvV/vlSSn0CVUlv
|
||||
VW5SL4SjK7OGYrNU0mNS2uOIdqDvixWl0xgUcndex6MEH54ZYrUbG57D8rUy+UzB
|
||||
qusMJn3UX0pRXKRFBnBEp1bA1CIUdp7YY1CJkNPiv4GVkjFBhzkaQwsYpVMfORpf
|
||||
H0O8h2rfbtMiAP4imHBOGhkpAoGBAIpBVihRnl/Ungs7mKNU8mxW1KrpaTOFJAza
|
||||
1AwtxL9PAmk4fNTm3Ezt1xYRwz4A58MmwFEC3rt1nG9WnHrzju/PisUr0toGakTJ
|
||||
c/5umYf4W77xfOZltU9s8MnF/xbKixsX4lg9ojerAby/QM5TjI7t7+5ZneBj5nxe
|
||||
9Y5L8TvBAoGATUX5QIzFW/QqGoq08hysa+kMVja3TnKW1eWK0uL/8fEYEz2GCbjY
|
||||
dqfJHHFSlDBD4PF4dP1hG0wJzOZoKnGtHN9DvFbbpaS+NXCkXs9P/ABVmTo9I89n
|
||||
WvUi+LUp0EQR6zUuRr79jhiyX6i/GTKh9dwD5nyaHwx8qbAOITc78bA=
|
||||
-----END RSA PRIVATE KEY-----
|
@ -1,108 +0,0 @@
|
||||
/*
|
||||
* FreeRTOS V202212.00
|
||||
* Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
* this software and associated documentation files (the "Software"), to deal in
|
||||
* the Software without restriction, including without limitation the rights to
|
||||
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||
* the Software, and to permit persons to whom the Software is furnished to do so,
|
||||
* subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* 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 OR
|
||||
* COPYRIGHT HOLDERS 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.
|
||||
*
|
||||
* https://www.FreeRTOS.org
|
||||
* https://github.com/FreeRTOS
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef USER_SETTINGS_H_
|
||||
#define USER_SETTINGS_H_
|
||||
/*-- Cipher related definitions -----------------------------------------------
|
||||
*
|
||||
*
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
||||
#define HAVE_FIPS
|
||||
#define HAVE_FIPS_VERSION 3
|
||||
#define WOLFSSL_TLS13
|
||||
#define HAVE_TLS_EXTENSIONS
|
||||
|
||||
#define HAVE_SUPPORTED_CURVES
|
||||
#define HAVE_FFDHE_2048
|
||||
|
||||
#ifndef WOLFSSL_OPTIONS_IGNORE_SYS
|
||||
#undef _POSIX_THREADS
|
||||
#define _POSIX_THREADS
|
||||
#endif
|
||||
|
||||
#define HAVE_THREAD_LS
|
||||
#define TFM_TIMING_RESISTANT
|
||||
#define ECC_TIMING_RESISTANT
|
||||
#define WC_RSA_BLINDING
|
||||
#define HAVE_AESGCM
|
||||
#define WOLFSSL_SHA512
|
||||
#define WOLFSSL_SHA384
|
||||
#define HAVE_HKDF
|
||||
#define NO_DSA
|
||||
#define HAVE_ECC
|
||||
#define TFM_ECC256
|
||||
#define ECC_SHAMIR
|
||||
#define WC_RSA_PSS
|
||||
#define WOLFSSL_BASE64_ENCODE
|
||||
#define NO_RC4
|
||||
#define NO_HC128
|
||||
#define NO_RABBIT
|
||||
#define WOLFSSL_KEY_GEN
|
||||
#define WOLFSSL_SHA224
|
||||
#define WOLFSSL_AES_DIRECT
|
||||
#define HAVE_AES_ECB
|
||||
#define HAVE_ECC_CDH
|
||||
#define WC_RSA_NO_PADDING
|
||||
#define WOLFSSL_VALIDATE_FFC_IMPORT
|
||||
#define HAVE_FFDHE_Q
|
||||
#define WOLFSSL_NO_SHAKE256
|
||||
#define HAVE_AESCCM
|
||||
#define WOLFSSL_VALIDATE_ECC_IMPORT
|
||||
#define WOLFSSL_AES_COUNTER
|
||||
#define WOLFSSL_CMAC
|
||||
#define WOLFSSL_SHA224
|
||||
#define WOLFSSL_SHA3
|
||||
#define WOLFSSL_SHAKE256
|
||||
#define HAVE_HASHDRBG
|
||||
#define HAVE_TLS_EXTENSIONS
|
||||
#define HAVE_SUPPORTED_CURVES
|
||||
#define HAVE_EXTENDED_MASTER
|
||||
#define NO_RC4
|
||||
#define HAVE_ENCRYPT_THEN_MAC
|
||||
#define NO_PSK
|
||||
#define NO_MD4
|
||||
#define NO_PWDBASED
|
||||
#define USE_FAST_MATH
|
||||
#define WOLFSSL_X86_64_BUILD
|
||||
#define WC_NO_ASYNC_THREADING
|
||||
#define HAVE_DH_DEFAULT_PARAMS
|
||||
#define HAVE___UINT128_T 1
|
||||
|
||||
|
||||
|
||||
/*-- Debugging options ------------------------------------------------------
|
||||
*
|
||||
* "DEBUG_WOLFSSL" definition enables log to output into stdout.
|
||||
* Note: wolfSSL_Debugging_ON() must be called just after wolfSSL_Init().
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
||||
/*#define DEBUG_WOLFSSL*/
|
||||
|
||||
/* The TCP port used by both the secure client and the secure server. */
|
||||
#define configTCP_PORT_NUMBER 5001
|
||||
|
||||
#endif /* ifndef USER_SETTINGS_H_ */
|
@ -1,339 +0,0 @@
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
Version 2, June 1991
|
||||
|
||||
Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
Preamble
|
||||
|
||||
The licenses for most software are designed to take away your
|
||||
freedom to share and change it. By contrast, the GNU General Public
|
||||
License is intended to guarantee your freedom to share and change free
|
||||
software--to make sure the software is free for all its users. This
|
||||
General Public License applies to most of the Free Software
|
||||
Foundation's software and to any other program whose authors commit to
|
||||
using it. (Some other Free Software Foundation software is covered by
|
||||
the GNU Lesser General Public License instead.) You can apply it to
|
||||
your programs, too.
|
||||
|
||||
When we speak of free software, we are referring to freedom, not
|
||||
price. Our General Public Licenses are designed to make sure that you
|
||||
have the freedom to distribute copies of free software (and charge for
|
||||
this service if you wish), that you receive source code or can get it
|
||||
if you want it, that you can change the software or use pieces of it
|
||||
in new free programs; and that you know you can do these things.
|
||||
|
||||
To protect your rights, we need to make restrictions that forbid
|
||||
anyone to deny you these rights or to ask you to surrender the rights.
|
||||
These restrictions translate to certain responsibilities for you if you
|
||||
distribute copies of the software, or if you modify it.
|
||||
|
||||
For example, if you distribute copies of such a program, whether
|
||||
gratis or for a fee, you must give the recipients all the rights that
|
||||
you have. You must make sure that they, too, receive or can get the
|
||||
source code. And you must show them these terms so they know their
|
||||
rights.
|
||||
|
||||
We protect your rights with two steps: (1) copyright the software, and
|
||||
(2) offer you this license which gives you legal permission to copy,
|
||||
distribute and/or modify the software.
|
||||
|
||||
Also, for each author's protection and ours, we want to make certain
|
||||
that everyone understands that there is no warranty for this free
|
||||
software. If the software is modified by someone else and passed on, we
|
||||
want its recipients to know that what they have is not the original, so
|
||||
that any problems introduced by others will not reflect on the original
|
||||
authors' reputations.
|
||||
|
||||
Finally, any free program is threatened constantly by software
|
||||
patents. We wish to avoid the danger that redistributors of a free
|
||||
program will individually obtain patent licenses, in effect making the
|
||||
program proprietary. To prevent this, we have made it clear that any
|
||||
patent must be licensed for everyone's free use or not licensed at all.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow.
|
||||
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
||||
|
||||
0. This License applies to any program or other work which contains
|
||||
a notice placed by the copyright holder saying it may be distributed
|
||||
under the terms of this General Public License. The "Program", below,
|
||||
refers to any such program or work, and a "work based on the Program"
|
||||
means either the Program or any derivative work under copyright law:
|
||||
that is to say, a work containing the Program or a portion of it,
|
||||
either verbatim or with modifications and/or translated into another
|
||||
language. (Hereinafter, translation is included without limitation in
|
||||
the term "modification".) Each licensee is addressed as "you".
|
||||
|
||||
Activities other than copying, distribution and modification are not
|
||||
covered by this License; they are outside its scope. The act of
|
||||
running the Program is not restricted, and the output from the Program
|
||||
is covered only if its contents constitute a work based on the
|
||||
Program (independent of having been made by running the Program).
|
||||
Whether that is true depends on what the Program does.
|
||||
|
||||
1. You may copy and distribute verbatim copies of the Program's
|
||||
source code as you receive it, in any medium, provided that you
|
||||
conspicuously and appropriately publish on each copy an appropriate
|
||||
copyright notice and disclaimer of warranty; keep intact all the
|
||||
notices that refer to this License and to the absence of any warranty;
|
||||
and give any other recipients of the Program a copy of this License
|
||||
along with the Program.
|
||||
|
||||
You may charge a fee for the physical act of transferring a copy, and
|
||||
you may at your option offer warranty protection in exchange for a fee.
|
||||
|
||||
2. You may modify your copy or copies of the Program or any portion
|
||||
of it, thus forming a work based on the Program, and copy and
|
||||
distribute such modifications or work under the terms of Section 1
|
||||
above, provided that you also meet all of these conditions:
|
||||
|
||||
a) You must cause the modified files to carry prominent notices
|
||||
stating that you changed the files and the date of any change.
|
||||
|
||||
b) You must cause any work that you distribute or publish, that in
|
||||
whole or in part contains or is derived from the Program or any
|
||||
part thereof, to be licensed as a whole at no charge to all third
|
||||
parties under the terms of this License.
|
||||
|
||||
c) If the modified program normally reads commands interactively
|
||||
when run, you must cause it, when started running for such
|
||||
interactive use in the most ordinary way, to print or display an
|
||||
announcement including an appropriate copyright notice and a
|
||||
notice that there is no warranty (or else, saying that you provide
|
||||
a warranty) and that users may redistribute the program under
|
||||
these conditions, and telling the user how to view a copy of this
|
||||
License. (Exception: if the Program itself is interactive but
|
||||
does not normally print such an announcement, your work based on
|
||||
the Program is not required to print an announcement.)
|
||||
|
||||
These requirements apply to the modified work as a whole. If
|
||||
identifiable sections of that work are not derived from the Program,
|
||||
and can be reasonably considered independent and separate works in
|
||||
themselves, then this License, and its terms, do not apply to those
|
||||
sections when you distribute them as separate works. But when you
|
||||
distribute the same sections as part of a whole which is a work based
|
||||
on the Program, the distribution of the whole must be on the terms of
|
||||
this License, whose permissions for other licensees extend to the
|
||||
entire whole, and thus to each and every part regardless of who wrote it.
|
||||
|
||||
Thus, it is not the intent of this section to claim rights or contest
|
||||
your rights to work written entirely by you; rather, the intent is to
|
||||
exercise the right to control the distribution of derivative or
|
||||
collective works based on the Program.
|
||||
|
||||
In addition, mere aggregation of another work not based on the Program
|
||||
with the Program (or with a work based on the Program) on a volume of
|
||||
a storage or distribution medium does not bring the other work under
|
||||
the scope of this License.
|
||||
|
||||
3. You may copy and distribute the Program (or a work based on it,
|
||||
under Section 2) in object code or executable form under the terms of
|
||||
Sections 1 and 2 above provided that you also do one of the following:
|
||||
|
||||
a) Accompany it with the complete corresponding machine-readable
|
||||
source code, which must be distributed under the terms of Sections
|
||||
1 and 2 above on a medium customarily used for software interchange; or,
|
||||
|
||||
b) Accompany it with a written offer, valid for at least three
|
||||
years, to give any third party, for a charge no more than your
|
||||
cost of physically performing source distribution, a complete
|
||||
machine-readable copy of the corresponding source code, to be
|
||||
distributed under the terms of Sections 1 and 2 above on a medium
|
||||
customarily used for software interchange; or,
|
||||
|
||||
c) Accompany it with the information you received as to the offer
|
||||
to distribute corresponding source code. (This alternative is
|
||||
allowed only for noncommercial distribution and only if you
|
||||
received the program in object code or executable form with such
|
||||
an offer, in accord with Subsection b above.)
|
||||
|
||||
The source code for a work means the preferred form of the work for
|
||||
making modifications to it. For an executable work, complete source
|
||||
code means all the source code for all modules it contains, plus any
|
||||
associated interface definition files, plus the scripts used to
|
||||
control compilation and installation of the executable. However, as a
|
||||
special exception, the source code distributed need not include
|
||||
anything that is normally distributed (in either source or binary
|
||||
form) with the major components (compiler, kernel, and so on) of the
|
||||
operating system on which the executable runs, unless that component
|
||||
itself accompanies the executable.
|
||||
|
||||
If distribution of executable or object code is made by offering
|
||||
access to copy from a designated place, then offering equivalent
|
||||
access to copy the source code from the same place counts as
|
||||
distribution of the source code, even though third parties are not
|
||||
compelled to copy the source along with the object code.
|
||||
|
||||
4. You may not copy, modify, sublicense, or distribute the Program
|
||||
except as expressly provided under this License. Any attempt
|
||||
otherwise to copy, modify, sublicense or distribute the Program is
|
||||
void, and will automatically terminate your rights under this License.
|
||||
However, parties who have received copies, or rights, from you under
|
||||
this License will not have their licenses terminated so long as such
|
||||
parties remain in full compliance.
|
||||
|
||||
5. You are not required to accept this License, since you have not
|
||||
signed it. However, nothing else grants you permission to modify or
|
||||
distribute the Program or its derivative works. These actions are
|
||||
prohibited by law if you do not accept this License. Therefore, by
|
||||
modifying or distributing the Program (or any work based on the
|
||||
Program), you indicate your acceptance of this License to do so, and
|
||||
all its terms and conditions for copying, distributing or modifying
|
||||
the Program or works based on it.
|
||||
|
||||
6. Each time you redistribute the Program (or any work based on the
|
||||
Program), the recipient automatically receives a license from the
|
||||
original licensor to copy, distribute or modify the Program subject to
|
||||
these terms and conditions. You may not impose any further
|
||||
restrictions on the recipients' exercise of the rights granted herein.
|
||||
You are not responsible for enforcing compliance by third parties to
|
||||
this License.
|
||||
|
||||
7. If, as a consequence of a court judgment or allegation of patent
|
||||
infringement or for any other reason (not limited to patent issues),
|
||||
conditions are imposed on you (whether by court order, agreement or
|
||||
otherwise) that contradict the conditions of this License, they do not
|
||||
excuse you from the conditions of this License. If you cannot
|
||||
distribute so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you
|
||||
may not distribute the Program at all. For example, if a patent
|
||||
license would not permit royalty-free redistribution of the Program by
|
||||
all those who receive copies directly or indirectly through you, then
|
||||
the only way you could satisfy both it and this License would be to
|
||||
refrain entirely from distribution of the Program.
|
||||
|
||||
If any portion of this section is held invalid or unenforceable under
|
||||
any particular circumstance, the balance of the section is intended to
|
||||
apply and the section as a whole is intended to apply in other
|
||||
circumstances.
|
||||
|
||||
It is not the purpose of this section to induce you to infringe any
|
||||
patents or other property right claims or to contest validity of any
|
||||
such claims; this section has the sole purpose of protecting the
|
||||
integrity of the free software distribution system, which is
|
||||
implemented by public license practices. Many people have made
|
||||
generous contributions to the wide range of software distributed
|
||||
through that system in reliance on consistent application of that
|
||||
system; it is up to the author/donor to decide if he or she is willing
|
||||
to distribute software through any other system and a licensee cannot
|
||||
impose that choice.
|
||||
|
||||
This section is intended to make thoroughly clear what is believed to
|
||||
be a consequence of the rest of this License.
|
||||
|
||||
8. If the distribution and/or use of the Program is restricted in
|
||||
certain countries either by patents or by copyrighted interfaces, the
|
||||
original copyright holder who places the Program under this License
|
||||
may add an explicit geographical distribution limitation excluding
|
||||
those countries, so that distribution is permitted only in or among
|
||||
countries not thus excluded. In such case, this License incorporates
|
||||
the limitation as if written in the body of this License.
|
||||
|
||||
9. The Free Software Foundation may publish revised and/or new versions
|
||||
of the General Public License from time to time. Such new versions will
|
||||
be similar in spirit to the present version, but may differ in detail to
|
||||
address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the Program
|
||||
specifies a version number of this License which applies to it and "any
|
||||
later version", you have the option of following the terms and conditions
|
||||
either of that version or of any later version published by the Free
|
||||
Software Foundation. If the Program does not specify a version number of
|
||||
this License, you may choose any version ever published by the Free Software
|
||||
Foundation.
|
||||
|
||||
10. If you wish to incorporate parts of the Program into other free
|
||||
programs whose distribution conditions are different, write to the author
|
||||
to ask for permission. For software which is copyrighted by the Free
|
||||
Software Foundation, write to the Free Software Foundation; we sometimes
|
||||
make exceptions for this. Our decision will be guided by the two goals
|
||||
of preserving the free status of all derivatives of our free software and
|
||||
of promoting the sharing and reuse of software generally.
|
||||
|
||||
NO WARRANTY
|
||||
|
||||
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
|
||||
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
|
||||
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
|
||||
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
|
||||
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
|
||||
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
|
||||
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
|
||||
REPAIR OR CORRECTION.
|
||||
|
||||
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
|
||||
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
|
||||
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
|
||||
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
|
||||
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
|
||||
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
|
||||
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGES.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
How to Apply These Terms to Your New Programs
|
||||
|
||||
If you develop a new program, and you want it to be of the greatest
|
||||
possible use to the public, the best way to achieve this is to make it
|
||||
free software which everyone can redistribute and change under these terms.
|
||||
|
||||
To do so, attach the following notices to the program. It is safest
|
||||
to attach them to the start of each source file to most effectively
|
||||
convey the exclusion of warranty; and each file should have at least
|
||||
the "copyright" line and a pointer to where the full notice is found.
|
||||
|
||||
<one line to give the program's name and a brief idea of what it does.>
|
||||
Copyright (C) <year> <name of author>
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License along
|
||||
with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
If the program is interactive, make it output a short notice like this
|
||||
when it starts in an interactive mode:
|
||||
|
||||
Gnomovision version 69, Copyright (C) year name of author
|
||||
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||
This is free software, and you are welcome to redistribute it
|
||||
under certain conditions; type `show c' for details.
|
||||
|
||||
The hypothetical commands `show w' and `show c' should show the appropriate
|
||||
parts of the General Public License. Of course, the commands you use may
|
||||
be called something other than `show w' and `show c'; they could even be
|
||||
mouse-clicks or menu items--whatever suits your program.
|
||||
|
||||
You should also get your employer (if you work as a programmer) or your
|
||||
school, if any, to sign a "copyright disclaimer" for the program, if
|
||||
necessary. Here is a sample; alter the names:
|
||||
|
||||
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
|
||||
`Gnomovision' (which makes passes at compilers) written by James Hacker.
|
||||
|
||||
<signature of Ty Coon>, 1 April 1989
|
||||
Ty Coon, President of Vice
|
||||
|
||||
This General Public License does not permit incorporating your program into
|
||||
proprietary programs. If your program is a subroutine library, you may
|
||||
consider it more useful to permit linking proprietary applications with the
|
||||
library. If this is what you want to do, use the GNU Lesser General
|
||||
Public License instead of this License.
|
File diff suppressed because it is too large
Load Diff
@ -1,102 +0,0 @@
|
||||
0. Building on *nix from git repository
|
||||
|
||||
Run the autogen script to generate configure, then proceed to step 1.
|
||||
Prerequisites: You'll need autoconf, automake and libtool installed.
|
||||
|
||||
$ ./autogen.sh
|
||||
|
||||
1. Building on *nix from a release
|
||||
|
||||
$ ./configure
|
||||
$ make
|
||||
$ make check # (optional, but highly recommended)
|
||||
$ sudo make install
|
||||
|
||||
2. Building on iOS
|
||||
|
||||
Use on the xcode project in IDE/iOS/wolfssl.xcodeproj
|
||||
There is a README in IDE/iOS with more information
|
||||
|
||||
3. Building on Windows
|
||||
|
||||
Use the 32bit Visual Studio Solution wolfssl.sln
|
||||
For a 64bit solution please use wolfssl64.sln
|
||||
|
||||
4. Building with IAR
|
||||
|
||||
Please see the README in IDE/IAR-EWARM for detailed instructions
|
||||
|
||||
5. Building with Keil
|
||||
|
||||
Please see the Keil Projects in IDE/MDK5-ARM/Projects
|
||||
|
||||
6. Building with Microchip tools
|
||||
|
||||
Please see the README in mplabx
|
||||
|
||||
7. Building with Freescale MQX
|
||||
|
||||
Please see the README in mqx
|
||||
|
||||
8. Building with Rowley CrossWorks for ARM
|
||||
|
||||
Use the CrossWorks project in IDE/ROWLEY-CROSSWORKS-ARM/wolfssl.hzp
|
||||
There is a README.md in IDE/ROWLEY-CROSSWORKS-ARM with more information
|
||||
|
||||
9. Building with Arduino
|
||||
|
||||
Use the script IDE/ARDUINO/wolfssl-arduino.sh to reformat the wolfSSL
|
||||
library for compatibility with the Arduino IDE. There is a README.md in
|
||||
IDE/ARDUINO for detailed instructions.
|
||||
|
||||
10. Building for Android with Visual Studio 2017
|
||||
|
||||
Please see the README in IDE/VS-ARM.
|
||||
Use the Visual Studio solution IDE/VS-ARM/wolfssl.sln.
|
||||
|
||||
11. Building for Yocto Project or OpenEmbedded
|
||||
|
||||
Please see the README in the "meta-wolfssl" repository. This repository
|
||||
holds wolfSSL's Yocto and OpenEmbedded layer, which contains recipes
|
||||
for wolfSSL, wolfSSH, wolfMQTT, wolfTPM, wolfCrypt examples, and OSS
|
||||
project bbappend files.
|
||||
|
||||
https://github.com/wolfssl/meta-wolfssl
|
||||
|
||||
The wolfSSL recipe can also be found in the OpenEmbedded
|
||||
"meta-openembedded/meta-networking/recipes-connectivity" layer:
|
||||
|
||||
https://github.com/openembedded/meta-openembedded
|
||||
|
||||
12. Porting to a new platform
|
||||
|
||||
Please see section 2.4 in the manual:
|
||||
http://www.wolfssl.com/yaSSL/Docs-cyassl-manual-2-building-cyassl.html
|
||||
|
||||
13. Building with CMake
|
||||
Note: Primary development uses automake (./configure). The support for CMake is minimal.
|
||||
|
||||
Internally cmake is setup to do the following:
|
||||
1. Uses the ./configure generated wolfssl/options.h as the build options by coping it to the build directory as user_settings.h.
|
||||
2. Builds wolfSSL as library.
|
||||
3. Builds the examples.
|
||||
|
||||
Build Steps:
|
||||
$ mkdir build
|
||||
$ cd build
|
||||
$ cmake ..
|
||||
$ cmake --build .
|
||||
$ cmake --install .
|
||||
|
||||
To build library only and not build examples and test apps use:
|
||||
$ cmake .. -DBUILD_TESTS=NO
|
||||
|
||||
To build with debugging use:
|
||||
$ cmake .. -DCMAKE_BUILD_TYPE=Debug
|
||||
|
||||
Make sure and run the built examples and test from the wolfssl-root to properly find the ./certs directory.
|
||||
|
||||
CMake on Windows with Visual Studio
|
||||
1. Open Command Prompt
|
||||
2. Run the Visual Studio batch to setup command line variables: Example: C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Auxiliary\Build\vcvars64.bat
|
||||
3. Then use steps above
|
@ -1,14 +0,0 @@
|
||||
|
||||
wolfSSL (formerly known as CyaSSL) and wolfCrypt are either licensed for use
|
||||
under the GPLv3 (or at your option any later version) or a standard commercial
|
||||
license. For our users who cannot use wolfSSL under GPLv3
|
||||
(or any later version), a commercial license to wolfSSL and wolfCrypt is
|
||||
available.
|
||||
|
||||
Please contact wolfSSL Inc. directly at:
|
||||
|
||||
Email: licensing@wolfssl.com
|
||||
Phone: +1 425 245-8247
|
||||
|
||||
More information can be found on the wolfSSL website at www.wolfssl.com.
|
||||
|
@ -1,265 +0,0 @@
|
||||
# includes append to these:
|
||||
SUFFIXES =
|
||||
TESTS =
|
||||
CLEANFILES =
|
||||
DISTCLEANFILES =
|
||||
bin_PROGRAMS =
|
||||
noinst_HEADERS =
|
||||
lib_LTLIBRARIES =
|
||||
man_MANS =
|
||||
noinst_LTLIBRARIES =
|
||||
noinst_PROGRAMS =
|
||||
include_HEADERS =
|
||||
nobase_include_HEADERS =
|
||||
check_PROGRAMS =
|
||||
EXTRA_HEADERS =
|
||||
BUILT_SOURCES=
|
||||
EXTRA_DIST=
|
||||
dist_doc_DATA=
|
||||
dist_noinst_SCRIPTS =
|
||||
noinst_SCRIPTS =
|
||||
check_SCRIPTS =
|
||||
|
||||
#includes additional rules from aminclude.am
|
||||
@INC_AMINCLUDE@
|
||||
DISTCLEANFILES+= aminclude.am
|
||||
|
||||
CLEANFILES+= cert.der \
|
||||
cert.pem \
|
||||
certecc.der \
|
||||
certecc.pem \
|
||||
certreq.der \
|
||||
certreq.pem \
|
||||
key.der \
|
||||
key.pem \
|
||||
ntru-cert.der \
|
||||
ecc-key-pkcs8.der \
|
||||
ntru-cert.pem \
|
||||
ntru-key.raw \
|
||||
othercert.der \
|
||||
othercert.pem \
|
||||
pkcs7cert.der \
|
||||
pkcs7authEnvelopedDataAES128GCM.der \
|
||||
pkcs7authEnvelopedDataAES128GCM_ECDH_SHA1KDF.der \
|
||||
pkcs7authEnvelopedDataAES128GCM_KEKRI.der \
|
||||
pkcs7authEnvelopedDataAES128GCM_ORI.der \
|
||||
pkcs7authEnvelopedDataAES128GCM_PWRI.der \
|
||||
pkcs7authEnvelopedDataAES192GCM.der \
|
||||
pkcs7authEnvelopedDataAES256GCM.der \
|
||||
pkcs7authEnvelopedDataAES256GCM_ECDH_SHA256KDF.der \
|
||||
pkcs7authEnvelopedDataAES256GCM_ECDH_SHA256KDF_authAttribs.der \
|
||||
pkcs7authEnvelopedDataAES256GCM_ECDH_SHA256KDF_bothAttribs.der \
|
||||
pkcs7authEnvelopedDataAES256GCM_ECDH_SHA256KDF_fw_bothAttribs.der \
|
||||
pkcs7authEnvelopedDataAES256GCM_ECDH_SHA256KDF_unauthAttribs.der \
|
||||
pkcs7authEnvelopedDataAES256GCM_ECDH_SHA512KDF.der \
|
||||
pkcs7authEnvelopedDataAES256GCM_ECDH_SHA512KDF_ukm.der \
|
||||
pkcs7authEnvelopedDataAES256GCM_firmwarePkgData.der \
|
||||
pkcs7authEnvelopedDataAES256GCM_IANDS.der \
|
||||
pkcs7authEnvelopedDataAES256GCM_SKID.der \
|
||||
pkcs7compressedData_data_zlib.der \
|
||||
pkcs7compressedData_firmwarePkgData_zlib.der \
|
||||
pkcs7encryptedDataAES128CBC.der \
|
||||
pkcs7encryptedDataAES192CBC.der \
|
||||
pkcs7encryptedDataAES256CBC_attribs.der \
|
||||
pkcs7encryptedDataAES256CBC.der \
|
||||
pkcs7encryptedDataAES256CBC_firmwarePkgData.der \
|
||||
pkcs7encryptedDataAES256CBC_multi_attribs.der \
|
||||
pkcs7encryptedDataDES3.der \
|
||||
pkcs7encryptedDataDES.der \
|
||||
pkcs7envelopedDataAES256CBC_ECDH.der \
|
||||
pkcs7envelopedDataAES128CBC_ECDH_SHA1KDF.der \
|
||||
pkcs7envelopedDataAES256CBC_ECDH_SHA256KDF.der \
|
||||
pkcs7envelopedDataAES256CBC_ECDH_SHA512KDF.der \
|
||||
pkcs7envelopedDataAES256CBC_ECDH_SHA512KDF_ukm.der \
|
||||
pkcs7envelopedDataDES3.der \
|
||||
pkcs7envelopedDataAES128CBC.der \
|
||||
pkcs7envelopedDataAES128CBC_KEKRI.der \
|
||||
pkcs7envelopedDataAES128CBC_PWRI.der \
|
||||
pkcs7envelopedDataAES128CBC_ORI.der \
|
||||
pkcs7envelopedDataAES192CBC.der \
|
||||
pkcs7envelopedDataAES256CBC.der \
|
||||
pkcs7envelopedDataAES256CBC_IANDS.der \
|
||||
pkcs7envelopedDataAES256CBC_SKID.der \
|
||||
pkcs7signedData_RSA_SHA.der \
|
||||
pkcs7signedData_RSA_SHA_noattr.der \
|
||||
pkcs7signedData_RSA_SHA224.der \
|
||||
pkcs7signedData_RSA_SHA256.der \
|
||||
pkcs7signedData_RSA_SHA256_firmwarePkgData.der \
|
||||
pkcs7signedData_RSA_SHA256_custom_contentType.der \
|
||||
pkcs7signedData_RSA_SHA256_with_ca_cert.der \
|
||||
pkcs7signedData_RSA_SHA256_SKID.der \
|
||||
pkcs7signedData_RSA_SHA256_detachedSig.der \
|
||||
pkcs7signedData_RSA_SHA384.der \
|
||||
pkcs7signedData_RSA_SHA512.der \
|
||||
pkcs7signedData_ECDSA_SHA.der \
|
||||
pkcs7signedData_ECDSA_SHA_noattr.der \
|
||||
pkcs7signedData_ECDSA_SHA224.der \
|
||||
pkcs7signedData_ECDSA_SHA256.der \
|
||||
pkcs7signedData_ECDSA_SHA256_firmwarePkgData.der \
|
||||
pkcs7signedData_ECDSA_SHA256_custom_contentType.der \
|
||||
pkcs7signedData_ECDSA_SHA256_SKID.der \
|
||||
pkcs7signedData_ECDSA_SHA384.der \
|
||||
pkcs7signedData_ECDSA_SHA512.der \
|
||||
pkcs7signedFirmwarePkgData_ECDSA_SHA256.der \
|
||||
pkcs7signedFirmwarePkgData_ECDSA_SHA256_SKID.der \
|
||||
pkcs7signedFirmwarePkgData_ECDSA_SHA256_noattr.der \
|
||||
pkcs7signedFirmwarePkgData_RSA_SHA256.der \
|
||||
pkcs7signedFirmwarePkgData_RSA_SHA256_SKID.der \
|
||||
pkcs7signedFirmwarePkgData_RSA_SHA256_noattr.der \
|
||||
pkcs7signedFirmwarePkgData_RSA_SHA256_with_ca_cert.der \
|
||||
pkcs7signedCompressedFirmwarePkgData_ECDSA_SHA256.der \
|
||||
pkcs7signedCompressedFirmwarePkgData_ECDSA_SHA256_noattr.der \
|
||||
pkcs7signedCompressedFirmwarePkgData_RSA_SHA256.der \
|
||||
pkcs7signedCompressedFirmwarePkgData_RSA_SHA256_noattr.der \
|
||||
pkcs7signedEncryptedFirmwarePkgData_RSA_SHA256.der \
|
||||
pkcs7signedEncryptedFirmwarePkgData_RSA_SHA256_noattr.der \
|
||||
pkcs7signedEncryptedFirmwarePkgData_ECDSA_SHA256.der \
|
||||
pkcs7signedEncryptedFirmwarePkgData_ECDSA_SHA256_noattr.der \
|
||||
pkcs7signedEncryptedCompressedFirmwarePkgData_ECDSA_SHA256.der \
|
||||
pkcs7signedEncryptedCompressedFirmwarePkgData_ECDSA_SHA256_noattr.der \
|
||||
pkcs7signedEncryptedCompressedFirmwarePkgData_RSA_SHA256.der \
|
||||
pkcs7signedEncryptedCompressedFirmwarePkgData_RSA_SHA256_noattr.der \
|
||||
tests/test-log-dump-to-file.txt
|
||||
|
||||
exampledir = $(docdir)/example
|
||||
dist_example_DATA=
|
||||
|
||||
ACLOCAL_AMFLAGS= -I m4
|
||||
|
||||
EXTRA_DIST+= lib/dummy
|
||||
|
||||
EXTRA_DIST+= wolfssl-ntru.vcproj
|
||||
EXTRA_DIST+= wolfssl.vcproj
|
||||
EXTRA_DIST+= wolfssl.vcxproj
|
||||
EXTRA_DIST+= wolfssl-ntru.sln
|
||||
EXTRA_DIST+= wolfssl.sln
|
||||
EXTRA_DIST+= wolfssl64.sln
|
||||
EXTRA_DIST+= valgrind-error.sh
|
||||
EXTRA_DIST+= valgrind-bash.supp
|
||||
EXTRA_DIST+= fips-hash.sh
|
||||
EXTRA_DIST+= gencertbuf.pl
|
||||
EXTRA_DIST+= README.md
|
||||
EXTRA_DIST+= README
|
||||
EXTRA_DIST+= ChangeLog.md
|
||||
EXTRA_DIST+= LICENSING
|
||||
EXTRA_DIST+= INSTALL
|
||||
EXTRA_DIST+= IPP
|
||||
EXTRA_DIST+= LPCExpresso.cproject
|
||||
EXTRA_DIST+= LPCExpresso.project
|
||||
EXTRA_DIST+= resource.h wolfssl.rc
|
||||
EXTRA_DIST+= CMakeLists.txt
|
||||
|
||||
include wrapper/include.am
|
||||
include cyassl/include.am
|
||||
include wolfssl/include.am
|
||||
include certs/include.am
|
||||
include doc/include.am
|
||||
include swig/include.am
|
||||
|
||||
include src/include.am
|
||||
include support/include.am
|
||||
include wolfcrypt/user-crypto/include.am
|
||||
include wolfcrypt/benchmark/include.am
|
||||
include wolfcrypt/src/include.am
|
||||
include wolfcrypt/test/include.am
|
||||
include examples/include.am
|
||||
include testsuite/include.am
|
||||
include tests/include.am
|
||||
include sslSniffer/sslSnifferTest/include.am
|
||||
include rpm/include.am
|
||||
|
||||
# Exclude references to non-DFSG sources from build files
|
||||
if !BUILD_DISTRO
|
||||
include mqx/util_lib/Sources/include.am
|
||||
include mqx/wolfcrypt_benchmark/Sources/include.am
|
||||
include mqx/wolfcrypt_test/Sources/include.am
|
||||
include mqx/wolfssl/include.am
|
||||
include mqx/wolfssl_client/Sources/include.am
|
||||
include mplabx/include.am
|
||||
include mplabx/wolfcrypt_benchmark.X/nbproject/include.am
|
||||
include mplabx/wolfcrypt_test.X/nbproject/include.am
|
||||
include mplabx/wolfssl.X/nbproject/include.am
|
||||
include mcapi/include.am
|
||||
include mcapi/wolfcrypt_mcapi.X/nbproject/include.am
|
||||
include mcapi/wolfcrypt_test.X/nbproject/include.am
|
||||
include mcapi/wolfssl.X/nbproject/include.am
|
||||
include mcapi/zlib.X/nbproject/include.am
|
||||
include tirtos/include.am
|
||||
include IDE/include.am
|
||||
endif
|
||||
include scripts/include.am
|
||||
|
||||
if USE_VALGRIND
|
||||
TESTS_ENVIRONMENT=./valgrind-error.sh
|
||||
endif
|
||||
|
||||
TEST_EXTENSIONS=.test
|
||||
TESTS += $(check_PROGRAMS)
|
||||
|
||||
check_SCRIPTS+= $(dist_noinst_SCRIPTS)
|
||||
TESTS += $(check_SCRIPTS)
|
||||
|
||||
test: check
|
||||
tests/unit.log: testsuite/testsuite.log
|
||||
|
||||
DISTCLEANFILES+= cyassl-config
|
||||
DISTCLEANFILES+= wolfssl-config
|
||||
|
||||
maintainer-clean-local:
|
||||
-rm Makefile.in
|
||||
-rm aclocal.m4
|
||||
-rm build-aux/compile
|
||||
-rm build-aux/config.guess
|
||||
-rm build-aux/config.sub
|
||||
-rm build-aux/depcomp
|
||||
-rm build-aux/install-sh
|
||||
-rm build-aux/ltmain.sh
|
||||
-rm build-aux/missing
|
||||
-rm cyassl-config
|
||||
-rmdir build-aux
|
||||
-rm configure
|
||||
-rm config.log
|
||||
-rm config.status
|
||||
-rm config.in
|
||||
-rm m4/libtool.m4
|
||||
-rm m4/ltoptions.m4
|
||||
-rm m4/ltsugar.m4
|
||||
-rm m4/ltversion.m4
|
||||
-rm m4/lt~obsolete.m4
|
||||
-rm support/wolfssl.pc
|
||||
find . -type f -name '*~' -exec rm -f '{}' \;
|
||||
-rm -f @PACKAGE@-*.tar.gz
|
||||
-rm -f @PACKAGE@-*.rpm
|
||||
|
||||
# !!!! first line of rule has to start with a hard (real) tab, not spaces
|
||||
egs:
|
||||
$(MAKE) examples/client/client; \
|
||||
$(MAKE) examples/echoclient/echoclient;\
|
||||
$(MAKE) examples/server/server; \
|
||||
$(MAKE) examples/echoserver/echoserver;
|
||||
|
||||
wc_egs:
|
||||
$(MAKE) wolfcrypt/test/testwolfcrypt; \
|
||||
$(MAKE) wolfcrypt/benchmark/benchmark;
|
||||
|
||||
install-exec-local: install-generic-config
|
||||
|
||||
install-generic-config:
|
||||
$(mkinstalldirs) $(DESTDIR)$(bindir)
|
||||
$(INSTALL_SCRIPT) @GENERIC_CONFIG@ $(DESTDIR)$(bindir)
|
||||
|
||||
uninstall-local:
|
||||
-rm -f $(DESTDIR)$(bindir)/@GENERIC_CONFIG@
|
||||
|
||||
merge-clean:
|
||||
@find ./ | $(GREP) \.gcda | xargs rm -f
|
||||
@find ./ | $(GREP) \.gcno | xargs rm -f
|
||||
@find ./ | $(GREP) \.gz | xargs rm -f
|
||||
@find ./ | $(GREP) \.orig | xargs rm -f
|
||||
@find ./ | $(GREP) \.rej | xargs rm -f
|
||||
@find ./ | $(GREP) \.rpm | xargs rm -f
|
||||
@find ./ | $(GREP) \.THIS | xargs rm -f
|
||||
@find ./ | $(GREP) \.OTHER | xargs rm -f
|
||||
@find ./ | $(GREP) \.BASE | xargs rm -f
|
||||
@find ./ | $(GREP) \~$$ | xargs rm -f
|
||||
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -1,190 +0,0 @@
|
||||
/* config.h. Generated from config.in by configure. */
|
||||
/* config.in. Generated from configure.ac by autoheader. */
|
||||
|
||||
/* Define if building universal (internal helper macro) */
|
||||
/* #undef AC_APPLE_UNIVERSAL_BUILD */
|
||||
|
||||
/* User RSA is being defined */
|
||||
#define BUILD_USER_RSA /**/
|
||||
|
||||
/* Define to 1 to enable debugging code. */
|
||||
#define DEBUG 0
|
||||
|
||||
/* Define to 1 if you have the <arpa/inet.h> header file. */
|
||||
#define HAVE_ARPA_INET_H 1
|
||||
|
||||
/* Define to 1 if you have the <dlfcn.h> header file. */
|
||||
#define HAVE_DLFCN_H 1
|
||||
|
||||
/* Define to 1 if you have the <errno.h> header file. */
|
||||
#define HAVE_ERRNO_H 1
|
||||
|
||||
/* Define to 1 if you have the <fcntl.h> header file. */
|
||||
#define HAVE_FCNTL_H 1
|
||||
|
||||
/* Define to 1 if you have the `getaddrinfo' function. */
|
||||
#define HAVE_GETADDRINFO 1
|
||||
|
||||
/* Define to 1 if you have the `gethostbyname' function. */
|
||||
#define HAVE_GETHOSTBYNAME 1
|
||||
|
||||
/* Define to 1 if you have the `gettimeofday' function. */
|
||||
#define HAVE_GETTIMEOFDAY 1
|
||||
|
||||
/* Define to 1 if you have the `gmtime_r' function. */
|
||||
#define HAVE_GMTIME_R 1
|
||||
|
||||
/* Define to 1 if you have the `inet_ntoa' function. */
|
||||
#define HAVE_INET_NTOA 1
|
||||
|
||||
/* Define to 1 if you have the <inttypes.h> header file. */
|
||||
#define HAVE_INTTYPES_H 1
|
||||
|
||||
/* Define to 1 if you have the <ippcp.h> header file. */
|
||||
/* #undef HAVE_IPPCP_H */
|
||||
|
||||
/* Define to 1 if you have the `network' library (-lnetwork). */
|
||||
/* #undef HAVE_LIBNETWORK */
|
||||
|
||||
/* Define to 1 if you have the `pthread' library (-lpthread). */
|
||||
/* #undef HAVE_LIBPTHREAD */
|
||||
|
||||
/* Define to 1 if you have the <limits.h> header file. */
|
||||
#define HAVE_LIMITS_H 1
|
||||
|
||||
/* Define to 1 if you have the <memory.h> header file. */
|
||||
#define HAVE_MEMORY_H 1
|
||||
|
||||
/* Define to 1 if you have the `memset' function. */
|
||||
#define HAVE_MEMSET 1
|
||||
|
||||
/* Define to 1 if you have the <netdb.h> header file. */
|
||||
#define HAVE_NETDB_H 1
|
||||
|
||||
/* Define to 1 if you have the <netinet/in.h> header file. */
|
||||
#define HAVE_NETINET_IN_H 1
|
||||
|
||||
/* Define to 1 if you have the <pcap/pcap.h> header file. */
|
||||
/* #undef HAVE_PCAP_PCAP_H */
|
||||
|
||||
/* Define if you have POSIX threads libraries and header files. */
|
||||
#define HAVE_PTHREAD 1
|
||||
|
||||
/* Have PTHREAD_PRIO_INHERIT. */
|
||||
#define HAVE_PTHREAD_PRIO_INHERIT 1
|
||||
|
||||
/* Define to 1 if you have the `socket' function. */
|
||||
#define HAVE_SOCKET 1
|
||||
|
||||
/* Define to 1 if you have the <stddef.h> header file. */
|
||||
#define HAVE_STDDEF_H 1
|
||||
|
||||
/* Define to 1 if you have the <stdint.h> header file. */
|
||||
#define HAVE_STDINT_H 1
|
||||
|
||||
/* Define to 1 if you have the <stdlib.h> header file. */
|
||||
#define HAVE_STDLIB_H 1
|
||||
|
||||
/* Define to 1 if you have the <strings.h> header file. */
|
||||
#define HAVE_STRINGS_H 1
|
||||
|
||||
/* Define to 1 if you have the <string.h> header file. */
|
||||
#define HAVE_STRING_H 1
|
||||
|
||||
/* Define to 1 if you have the <sys/ioctl.h> header file. */
|
||||
#define HAVE_SYS_IOCTL_H 1
|
||||
|
||||
/* Define to 1 if you have the <sys/socket.h> header file. */
|
||||
#define HAVE_SYS_SOCKET_H 1
|
||||
|
||||
/* Define to 1 if you have the <sys/stat.h> header file. */
|
||||
#define HAVE_SYS_STAT_H 1
|
||||
|
||||
/* Define to 1 if you have the <sys/time.h> header file. */
|
||||
#define HAVE_SYS_TIME_H 1
|
||||
|
||||
/* Define to 1 if you have the <sys/types.h> header file. */
|
||||
#define HAVE_SYS_TYPES_H 1
|
||||
|
||||
/* Define to 1 if you have the <unistd.h> header file. */
|
||||
#define HAVE_UNISTD_H 1
|
||||
|
||||
/* Define to 1 or 0, depending whether the compiler supports simple visibility
|
||||
declarations. */
|
||||
#define HAVE_VISIBILITY 1
|
||||
|
||||
/* Define to 1 if the system has the type `__uint128_t'. */
|
||||
#define HAVE___UINT128_T 1
|
||||
|
||||
/* Define to the sub-directory where libtool stores uninstalled libraries. */
|
||||
#define LT_OBJDIR ".libs/"
|
||||
|
||||
/* Define to the address where bug reports for this package should be sent. */
|
||||
#define PACKAGE_BUGREPORT "https://github.com/wolfssl/wolfssl/issues"
|
||||
|
||||
/* Define to the full name of this package. */
|
||||
#define PACKAGE_NAME "wolfssl"
|
||||
|
||||
/* Define to the full name and version of this package. */
|
||||
#define PACKAGE_STRING "wolfssl 4.4.0"
|
||||
|
||||
/* Define to the one symbol short name of this package. */
|
||||
#define PACKAGE_TARNAME "wolfssl"
|
||||
|
||||
/* Define to the home page for this package. */
|
||||
#define PACKAGE_URL "https://www.wolfssl.com"
|
||||
|
||||
/* Define to the version of this package. */
|
||||
#define PACKAGE_VERSION "4.4.0"
|
||||
|
||||
/* Define to necessary symbol if this constant uses a non-standard name on
|
||||
your system. */
|
||||
/* #undef PTHREAD_CREATE_JOINABLE */
|
||||
|
||||
/* The size of `long', as computed by sizeof. */
|
||||
#define SIZEOF_LONG 8
|
||||
|
||||
/* The size of `long long', as computed by sizeof. */
|
||||
#define SIZEOF_LONG_LONG 8
|
||||
|
||||
/* The size of `time_t', as computed by sizeof. */
|
||||
#define SIZEOF_TIME_T 8
|
||||
|
||||
/* Define to 1 if you have the ANSI C header files. */
|
||||
#define STDC_HEADERS 1
|
||||
|
||||
/* If the compiler supports a TLS storage class define it to that here */
|
||||
#define TLS __thread
|
||||
|
||||
/* Define if the code was built from VCS. */
|
||||
#define VCS_CHECKOUT 0
|
||||
|
||||
/* VCS system */
|
||||
#define VCS_SYSTEM "none"
|
||||
|
||||
/* Use __declspec(dllexport) when building library */
|
||||
/* #undef WOLFSSL_DLL */
|
||||
|
||||
/* Define WORDS_BIGENDIAN to 1 if your processor stores words with the most
|
||||
significant byte first (like Motorola and SPARC, unlike Intel). */
|
||||
#if defined AC_APPLE_UNIVERSAL_BUILD
|
||||
# if defined __BIG_ENDIAN__
|
||||
# define WORDS_BIGENDIAN 1
|
||||
# endif
|
||||
#else
|
||||
# ifndef WORDS_BIGENDIAN
|
||||
/* # undef WORDS_BIGENDIAN */
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* Define for Solaris 2.5.1 so the uint8_t typedef from <sys/synch.h>,
|
||||
<pthread.h>, or <semaphore.h> is not used. If the typedef were allowed, the
|
||||
#define below would cause a syntax error. */
|
||||
/* #undef _UINT8_T */
|
||||
|
||||
/* Define to `unsigned int' if <sys/types.h> does not define. */
|
||||
/* #undef size_t */
|
||||
|
||||
/* Define to the type of an unsigned integer type of width exactly 8 bits if
|
||||
such a type exists and the standard includes do not define it. */
|
||||
/* #undef uint8_t */
|
@ -1,189 +0,0 @@
|
||||
/* config.in. Generated from configure.ac by autoheader. */
|
||||
|
||||
/* Define if building universal (internal helper macro) */
|
||||
#undef AC_APPLE_UNIVERSAL_BUILD
|
||||
|
||||
/* User RSA is being defined */
|
||||
#undef BUILD_USER_RSA
|
||||
|
||||
/* Define to 1 to enable debugging code. */
|
||||
#undef DEBUG
|
||||
|
||||
/* Define to 1 if you have the <arpa/inet.h> header file. */
|
||||
#undef HAVE_ARPA_INET_H
|
||||
|
||||
/* Define to 1 if you have the <dlfcn.h> header file. */
|
||||
#undef HAVE_DLFCN_H
|
||||
|
||||
/* Define to 1 if you have the <errno.h> header file. */
|
||||
#undef HAVE_ERRNO_H
|
||||
|
||||
/* Define to 1 if you have the <fcntl.h> header file. */
|
||||
#undef HAVE_FCNTL_H
|
||||
|
||||
/* Define to 1 if you have the `getaddrinfo' function. */
|
||||
#undef HAVE_GETADDRINFO
|
||||
|
||||
/* Define to 1 if you have the `gethostbyname' function. */
|
||||
#undef HAVE_GETHOSTBYNAME
|
||||
|
||||
/* Define to 1 if you have the `gettimeofday' function. */
|
||||
#undef HAVE_GETTIMEOFDAY
|
||||
|
||||
/* Define to 1 if you have the `gmtime_r' function. */
|
||||
#undef HAVE_GMTIME_R
|
||||
|
||||
/* Define to 1 if you have the `inet_ntoa' function. */
|
||||
#undef HAVE_INET_NTOA
|
||||
|
||||
/* Define to 1 if you have the <inttypes.h> header file. */
|
||||
#undef HAVE_INTTYPES_H
|
||||
|
||||
/* Define to 1 if you have the <ippcp.h> header file. */
|
||||
#undef HAVE_IPPCP_H
|
||||
|
||||
/* Define to 1 if you have the `network' library (-lnetwork). */
|
||||
#undef HAVE_LIBNETWORK
|
||||
|
||||
/* Define to 1 if you have the `pthread' library (-lpthread). */
|
||||
#undef HAVE_LIBPTHREAD
|
||||
|
||||
/* Define to 1 if you have the <limits.h> header file. */
|
||||
#undef HAVE_LIMITS_H
|
||||
|
||||
/* Define to 1 if you have the <memory.h> header file. */
|
||||
#undef HAVE_MEMORY_H
|
||||
|
||||
/* Define to 1 if you have the `memset' function. */
|
||||
#undef HAVE_MEMSET
|
||||
|
||||
/* Define to 1 if you have the <netdb.h> header file. */
|
||||
#undef HAVE_NETDB_H
|
||||
|
||||
/* Define to 1 if you have the <netinet/in.h> header file. */
|
||||
#undef HAVE_NETINET_IN_H
|
||||
|
||||
/* Define to 1 if you have the <pcap/pcap.h> header file. */
|
||||
#undef HAVE_PCAP_PCAP_H
|
||||
|
||||
/* Define if you have POSIX threads libraries and header files. */
|
||||
#undef HAVE_PTHREAD
|
||||
|
||||
/* Have PTHREAD_PRIO_INHERIT. */
|
||||
#undef HAVE_PTHREAD_PRIO_INHERIT
|
||||
|
||||
/* Define to 1 if you have the `socket' function. */
|
||||
#undef HAVE_SOCKET
|
||||
|
||||
/* Define to 1 if you have the <stddef.h> header file. */
|
||||
#undef HAVE_STDDEF_H
|
||||
|
||||
/* Define to 1 if you have the <stdint.h> header file. */
|
||||
#undef HAVE_STDINT_H
|
||||
|
||||
/* Define to 1 if you have the <stdlib.h> header file. */
|
||||
#undef HAVE_STDLIB_H
|
||||
|
||||
/* Define to 1 if you have the <strings.h> header file. */
|
||||
#undef HAVE_STRINGS_H
|
||||
|
||||
/* Define to 1 if you have the <string.h> header file. */
|
||||
#undef HAVE_STRING_H
|
||||
|
||||
/* Define to 1 if you have the <sys/ioctl.h> header file. */
|
||||
#undef HAVE_SYS_IOCTL_H
|
||||
|
||||
/* Define to 1 if you have the <sys/socket.h> header file. */
|
||||
#undef HAVE_SYS_SOCKET_H
|
||||
|
||||
/* Define to 1 if you have the <sys/stat.h> header file. */
|
||||
#undef HAVE_SYS_STAT_H
|
||||
|
||||
/* Define to 1 if you have the <sys/time.h> header file. */
|
||||
#undef HAVE_SYS_TIME_H
|
||||
|
||||
/* Define to 1 if you have the <sys/types.h> header file. */
|
||||
#undef HAVE_SYS_TYPES_H
|
||||
|
||||
/* Define to 1 if you have the <unistd.h> header file. */
|
||||
#undef HAVE_UNISTD_H
|
||||
|
||||
/* Define to 1 or 0, depending whether the compiler supports simple visibility
|
||||
declarations. */
|
||||
#undef HAVE_VISIBILITY
|
||||
|
||||
/* Define to 1 if the system has the type `__uint128_t'. */
|
||||
#undef HAVE___UINT128_T
|
||||
|
||||
/* Define to the sub-directory where libtool stores uninstalled libraries. */
|
||||
#undef LT_OBJDIR
|
||||
|
||||
/* Define to the address where bug reports for this package should be sent. */
|
||||
#undef PACKAGE_BUGREPORT
|
||||
|
||||
/* Define to the full name of this package. */
|
||||
#undef PACKAGE_NAME
|
||||
|
||||
/* Define to the full name and version of this package. */
|
||||
#undef PACKAGE_STRING
|
||||
|
||||
/* Define to the one symbol short name of this package. */
|
||||
#undef PACKAGE_TARNAME
|
||||
|
||||
/* Define to the home page for this package. */
|
||||
#undef PACKAGE_URL
|
||||
|
||||
/* Define to the version of this package. */
|
||||
#undef PACKAGE_VERSION
|
||||
|
||||
/* Define to necessary symbol if this constant uses a non-standard name on
|
||||
your system. */
|
||||
#undef PTHREAD_CREATE_JOINABLE
|
||||
|
||||
/* The size of `long', as computed by sizeof. */
|
||||
#undef SIZEOF_LONG
|
||||
|
||||
/* The size of `long long', as computed by sizeof. */
|
||||
#undef SIZEOF_LONG_LONG
|
||||
|
||||
/* The size of `time_t', as computed by sizeof. */
|
||||
#undef SIZEOF_TIME_T
|
||||
|
||||
/* Define to 1 if you have the ANSI C header files. */
|
||||
#undef STDC_HEADERS
|
||||
|
||||
/* If the compiler supports a TLS storage class define it to that here */
|
||||
#undef TLS
|
||||
|
||||
/* Define if the code was built from VCS. */
|
||||
#undef VCS_CHECKOUT
|
||||
|
||||
/* VCS system */
|
||||
#undef VCS_SYSTEM
|
||||
|
||||
/* Use __declspec(dllexport) when building library */
|
||||
#undef WOLFSSL_DLL
|
||||
|
||||
/* Define WORDS_BIGENDIAN to 1 if your processor stores words with the most
|
||||
significant byte first (like Motorola and SPARC, unlike Intel). */
|
||||
#if defined AC_APPLE_UNIVERSAL_BUILD
|
||||
# if defined __BIG_ENDIAN__
|
||||
# define WORDS_BIGENDIAN 1
|
||||
# endif
|
||||
#else
|
||||
# ifndef WORDS_BIGENDIAN
|
||||
# undef WORDS_BIGENDIAN
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* Define for Solaris 2.5.1 so the uint8_t typedef from <sys/synch.h>,
|
||||
<pthread.h>, or <semaphore.h> is not used. If the typedef were allowed, the
|
||||
#define below would cause a syntax error. */
|
||||
#undef _UINT8_T
|
||||
|
||||
/* Define to `unsigned int' if <sys/types.h> does not define. */
|
||||
#undef size_t
|
||||
|
||||
/* Define to the type of an unsigned integer type of width exactly 8 bits if
|
||||
such a type exists and the standard includes do not define it. */
|
||||
#undef uint8_t
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -1,21 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
if test ! -x ./wolfcrypt/test/testwolfcrypt
|
||||
then
|
||||
echo "fips-hash: wolfCrypt test missing"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if test ! -s ./wolfcrypt/src/fips_test.c
|
||||
then
|
||||
echo "fips-hash: fips_test.c missing"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
NEWHASH=$(./wolfcrypt/test/testwolfcrypt | sed -n 's/hash = \(.*\)/\1/p')
|
||||
if test -n "$NEWHASH"
|
||||
then
|
||||
cp wolfcrypt/src/fips_test.c wolfcrypt/src/fips_test.c.bak
|
||||
sed "s/^\".*\";/\"${NEWHASH}\";/" wolfcrypt/src/fips_test.c.bak >wolfcrypt/src/fips_test.c
|
||||
fi
|
||||
|
@ -1,283 +0,0 @@
|
||||
#!/usr/bin/perl
|
||||
|
||||
# gencertbuf.pl
|
||||
# version 1.1
|
||||
# Updated 07/01/2014
|
||||
#
|
||||
# Copyright (C) 2006-2015 wolfSSL Inc.
|
||||
#
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
# ---- SCRIPT SETTINGS -------------------------------------------------------
|
||||
|
||||
# output C header file to write cert/key buffers to
|
||||
my $outputFile = "./wolfssl/certs_test.h";
|
||||
|
||||
# ecc keys and certs to be converted
|
||||
# Used with HAVE_ECC && USE_CERT_BUFFERS_256
|
||||
|
||||
my @fileList_ecc = (
|
||||
[ "./certs/ecc-client-key.der", "ecc_clikey_der_256" ],
|
||||
[ "./certs/ecc-client-keyPub.der", "ecc_clikeypub_der_256" ],
|
||||
[ "./certs/client-ecc-cert.der", "cliecc_cert_der_256" ],
|
||||
[ "./certs/ecc-key.der", "ecc_key_der_256" ],
|
||||
[ "./certs/ecc-keyPub.der", "ecc_key_pub_der_256" ],
|
||||
[ "./certs/server-ecc-comp.der", "serv_ecc_comp_der_256" ],
|
||||
[ "./certs/server-ecc-rsa.der", "serv_ecc_rsa_der_256" ],
|
||||
[ "./certs/server-ecc.der", "serv_ecc_der_256" ],
|
||||
[ "./certs/ca-ecc-key.der", "ca_ecc_key_der_256" ],
|
||||
[ "./certs/ca-ecc-cert.der", "ca_ecc_cert_der_256" ],
|
||||
[ "./certs/ca-ecc384-key.der", "ca_ecc_key_der_384" ],
|
||||
[ "./certs/ca-ecc384-cert.der", "ca_ecc_cert_der_384" ]
|
||||
);
|
||||
|
||||
|
||||
# ed25519 keys and certs
|
||||
# Used with HAVE_ED25519 define.
|
||||
my @fileList_ed = (
|
||||
[ "./certs/ed25519/server-ed25519.der", "server_ed25519_cert" ],
|
||||
[ "./certs/ed25519/server-ed25519-key.der", "server_ed25519_key" ],
|
||||
[ "./certs/ed25519/ca-ed25519.der", "ca_ed25519_cert" ],
|
||||
[ "./certs/ed25519/client-ed25519.der", "client_ed25519_cert" ],
|
||||
[ "./certs/ed25519/client-ed25519-key.der", "client_ed25519_key" ]
|
||||
);
|
||||
|
||||
# 1024-bit certs/keys to be converted
|
||||
# Used with USE_CERT_BUFFERS_1024 define.
|
||||
|
||||
my @fileList_1024 = (
|
||||
[ "./certs/1024/client-key.der", "client_key_der_1024" ],
|
||||
[ "./certs/1024/client-keyPub.der", "client_keypub_der_1024" ],
|
||||
[ "./certs/1024/client-cert.der", "client_cert_der_1024" ],
|
||||
[ "./certs/1024/dh1024.der", "dh_key_der_1024" ],
|
||||
[ "./certs/1024/dsa1024.der", "dsa_key_der_1024" ],
|
||||
[ "./certs/1024/rsa1024.der", "rsa_key_der_1024" ],
|
||||
[ "./certs/1024/ca-key.der", "ca_key_der_1024"],
|
||||
[ "./certs/1024/ca-cert.der", "ca_cert_der_1024" ],
|
||||
[ "./certs/1024/server-key.der", "server_key_der_1024" ],
|
||||
[ "./certs/1024/server-cert.der", "server_cert_der_1024" ]
|
||||
);
|
||||
|
||||
# 2048-bit certs/keys to be converted
|
||||
# Used with USE_CERT_BUFFERS_2048 define.
|
||||
my @fileList_2048 = (
|
||||
[ "./certs/client-key.der", "client_key_der_2048" ],
|
||||
[ "./certs/client-keyPub.der", "client_keypub_der_2048" ],
|
||||
[ "./certs/client-cert.der", "client_cert_der_2048" ],
|
||||
[ "./certs/dh2048.der", "dh_key_der_2048" ],
|
||||
[ "./certs/dsa2048.der", "dsa_key_der_2048" ],
|
||||
[ "./certs/rsa2048.der", "rsa_key_der_2048" ],
|
||||
[ "./certs/ca-key.der", "ca_key_der_2048" ],
|
||||
[ "./certs/ca-cert.der", "ca_cert_der_2048" ],
|
||||
[ "./certs/ca-cert-chain.der", "ca_cert_chain_der" ],
|
||||
[ "./certs/server-key.der", "server_key_der_2048" ],
|
||||
[ "./certs/server-cert.der", "server_cert_der_2048" ]
|
||||
);
|
||||
|
||||
# 3072-bit certs/keys to be converted
|
||||
# Used with USE_CERT_BUFFERS_3072 define.
|
||||
my @fileList_3072 = (
|
||||
[ "./certs/dh3072.der", "dh_key_der_3072" ],
|
||||
[ "./certs/dsa3072.der", "dsa_key_der_3072" ],
|
||||
[ "./certs/rsa3072.der", "rsa_key_der_3072" ],
|
||||
[ "./certs/3072/client-key.der", "client_key_der_3072" ],
|
||||
[ "./certs/3072/client-keyPub.der", "client_keypub_der_3072" ],
|
||||
[ "./certs/3072/client-cert.der", "client_cert_der_3072" ],
|
||||
);
|
||||
|
||||
# 4096-bit certs/keys to be converted
|
||||
# Used with USE_CERT_BUFFERS_4096 define.
|
||||
my @fileList_4096 = (
|
||||
[ "./certs/4096/client-key.der", "client_key_der_4096" ],
|
||||
[ "./certs/4096/client-keyPub.der", "client_keypub_der_4096" ],
|
||||
[ "./certs/4096/client-cert.der", "client_cert_der_4096" ],
|
||||
[ "./certs/dh4096.der", "dh_key_der_4096" ],
|
||||
);
|
||||
|
||||
# ----------------------------------------------------------------------------
|
||||
|
||||
my $num_ecc = @fileList_ecc;
|
||||
my $num_ed = @fileList_ed;
|
||||
my $num_1024 = @fileList_1024;
|
||||
my $num_2048 = @fileList_2048;
|
||||
my $num_3072 = @fileList_3072;
|
||||
my $num_4096 = @fileList_4096;
|
||||
|
||||
# open our output file, "+>" creates and/or truncates
|
||||
open OUT_FILE, "+>", $outputFile or die $!;
|
||||
|
||||
print OUT_FILE "/* certs_test.h */\n\n";
|
||||
print OUT_FILE "#ifndef WOLFSSL_CERTS_TEST_H\n";
|
||||
print OUT_FILE "#define WOLFSSL_CERTS_TEST_H\n\n";
|
||||
|
||||
|
||||
# convert and print 1024-bit cert/keys
|
||||
print OUT_FILE "#ifdef USE_CERT_BUFFERS_1024\n\n";
|
||||
for (my $i = 0; $i < $num_1024; $i++) {
|
||||
|
||||
my $fname = $fileList_1024[$i][0];
|
||||
my $sname = $fileList_1024[$i][1];
|
||||
|
||||
print OUT_FILE "/* $fname, 1024-bit */\n";
|
||||
print OUT_FILE "static const unsigned char $sname\[] =\n";
|
||||
print OUT_FILE "{\n";
|
||||
file_to_hex($fname);
|
||||
print OUT_FILE "};\n";
|
||||
print OUT_FILE "static const int sizeof_$sname = sizeof($sname);\n\n";
|
||||
}
|
||||
print OUT_FILE "#endif /* USE_CERT_BUFFERS_1024 */\n\n";
|
||||
|
||||
|
||||
# convert and print 2048-bit certs/keys
|
||||
print OUT_FILE "#ifdef USE_CERT_BUFFERS_2048\n\n";
|
||||
for (my $i = 0; $i < $num_2048; $i++) {
|
||||
|
||||
my $fname = $fileList_2048[$i][0];
|
||||
my $sname = $fileList_2048[$i][1];
|
||||
|
||||
print OUT_FILE "/* $fname, 2048-bit */\n";
|
||||
print OUT_FILE "static const unsigned char $sname\[] =\n";
|
||||
print OUT_FILE "{\n";
|
||||
file_to_hex($fname);
|
||||
print OUT_FILE "};\n";
|
||||
print OUT_FILE "static const int sizeof_$sname = sizeof($sname);\n\n";
|
||||
}
|
||||
|
||||
|
||||
print OUT_FILE "#endif /* USE_CERT_BUFFERS_2048 */\n\n";
|
||||
|
||||
|
||||
# convert and print 3072-bit certs/keys
|
||||
print OUT_FILE "#ifdef USE_CERT_BUFFERS_3072\n\n";
|
||||
for (my $i = 0; $i < $num_3072; $i++) {
|
||||
|
||||
my $fname = $fileList_3072[$i][0];
|
||||
my $sname = $fileList_3072[$i][1];
|
||||
|
||||
print OUT_FILE "/* $fname, 3072-bit */\n";
|
||||
print OUT_FILE "static const unsigned char $sname\[] =\n";
|
||||
print OUT_FILE "{\n";
|
||||
file_to_hex($fname);
|
||||
print OUT_FILE "};\n";
|
||||
print OUT_FILE "static const int sizeof_$sname = sizeof($sname);\n\n";
|
||||
}
|
||||
|
||||
print OUT_FILE "#endif /* USE_CERT_BUFFERS_3072 */\n\n";
|
||||
|
||||
|
||||
# convert and print 4096-bit certs/keys
|
||||
print OUT_FILE "#ifdef USE_CERT_BUFFERS_4096\n\n";
|
||||
for (my $i = 0; $i < $num_4096; $i++) {
|
||||
|
||||
my $fname = $fileList_4096[$i][0];
|
||||
my $sname = $fileList_4096[$i][1];
|
||||
|
||||
print OUT_FILE "/* $fname, 4096-bit */\n";
|
||||
print OUT_FILE "static const unsigned char $sname\[] =\n";
|
||||
print OUT_FILE "{\n";
|
||||
file_to_hex($fname);
|
||||
print OUT_FILE "};\n";
|
||||
print OUT_FILE "static const int sizeof_$sname = sizeof($sname);\n\n";
|
||||
}
|
||||
|
||||
print OUT_FILE "#endif /* USE_CERT_BUFFERS_4096 */\n\n";
|
||||
|
||||
|
||||
# convert and print 256-bit cert/keys
|
||||
print OUT_FILE "#if defined(HAVE_ECC) && defined(USE_CERT_BUFFERS_256)\n\n";
|
||||
for (my $i = 0; $i < $num_ecc; $i++) {
|
||||
|
||||
my $fname = $fileList_ecc[$i][0];
|
||||
my $sname = $fileList_ecc[$i][1];
|
||||
|
||||
print OUT_FILE "/* $fname, ECC */\n";
|
||||
print OUT_FILE "static const unsigned char $sname\[] =\n";
|
||||
print OUT_FILE "{\n";
|
||||
file_to_hex($fname);
|
||||
print OUT_FILE "};\n";
|
||||
print OUT_FILE "static const int sizeof_$sname = sizeof($sname);\n\n";
|
||||
}
|
||||
print OUT_FILE "#endif /* HAVE_ECC && USE_CERT_BUFFERS_256 */\n\n";
|
||||
|
||||
|
||||
print OUT_FILE "/* dh1024 p */
|
||||
static const unsigned char dh_p[] =
|
||||
{
|
||||
0xE6, 0x96, 0x9D, 0x3D, 0x49, 0x5B, 0xE3, 0x2C, 0x7C, 0xF1, 0x80, 0xC3,
|
||||
0xBD, 0xD4, 0x79, 0x8E, 0x91, 0xB7, 0x81, 0x82, 0x51, 0xBB, 0x05, 0x5E,
|
||||
0x2A, 0x20, 0x64, 0x90, 0x4A, 0x79, 0xA7, 0x70, 0xFA, 0x15, 0xA2, 0x59,
|
||||
0xCB, 0xD5, 0x23, 0xA6, 0xA6, 0xEF, 0x09, 0xC4, 0x30, 0x48, 0xD5, 0xA2,
|
||||
0x2F, 0x97, 0x1F, 0x3C, 0x20, 0x12, 0x9B, 0x48, 0x00, 0x0E, 0x6E, 0xDD,
|
||||
0x06, 0x1C, 0xBC, 0x05, 0x3E, 0x37, 0x1D, 0x79, 0x4E, 0x53, 0x27, 0xDF,
|
||||
0x61, 0x1E, 0xBB, 0xBE, 0x1B, 0xAC, 0x9B, 0x5C, 0x60, 0x44, 0xCF, 0x02,
|
||||
0x3D, 0x76, 0xE0, 0x5E, 0xEA, 0x9B, 0xAD, 0x99, 0x1B, 0x13, 0xA6, 0x3C,
|
||||
0x97, 0x4E, 0x9E, 0xF1, 0x83, 0x9E, 0xB5, 0xDB, 0x12, 0x51, 0x36, 0xF7,
|
||||
0x26, 0x2E, 0x56, 0xA8, 0x87, 0x15, 0x38, 0xDF, 0xD8, 0x23, 0xC6, 0x50,
|
||||
0x50, 0x85, 0xE2, 0x1F, 0x0D, 0xD5, 0xC8, 0x6B,
|
||||
};
|
||||
|
||||
/* dh1024 g */
|
||||
static const unsigned char dh_g[] =
|
||||
{
|
||||
0x02,
|
||||
};\n\n";
|
||||
|
||||
# convert and print ed25519 cert/keys
|
||||
print OUT_FILE "#if defined(HAVE_ED25519)\n\n";
|
||||
for (my $i = 0; $i < $num_ed; $i++) {
|
||||
|
||||
my $fname = $fileList_ed[$i][0];
|
||||
my $sname = $fileList_ed[$i][1];
|
||||
|
||||
print OUT_FILE "/* $fname, ED25519 */\n";
|
||||
print OUT_FILE "static const unsigned char $sname\[] =\n";
|
||||
print OUT_FILE "{\n";
|
||||
file_to_hex($fname);
|
||||
print OUT_FILE "};\n";
|
||||
print OUT_FILE "static const int sizeof_$sname = sizeof($sname);\n\n";
|
||||
}
|
||||
print OUT_FILE "#endif /* HAVE_ED25519 */\n\n";
|
||||
|
||||
print OUT_FILE "#endif /* WOLFSSL_CERTS_TEST_H */\n\n";
|
||||
|
||||
# close certs_test.h file
|
||||
close OUT_FILE or die $!;
|
||||
|
||||
# print file as hex, comma-separated, as needed by C buffer
|
||||
sub file_to_hex {
|
||||
my $fileName = $_[0];
|
||||
|
||||
open my $fp, "<", $fileName or die $!;
|
||||
binmode($fp);
|
||||
|
||||
my $fileLen = -s $fileName;
|
||||
my $byte;
|
||||
|
||||
for (my $i = 0, my $j = 1; $i < $fileLen; $i++, $j++)
|
||||
{
|
||||
if ($j == 1) {
|
||||
print OUT_FILE " ";
|
||||
}
|
||||
if ($j != 1) {
|
||||
print OUT_FILE " ";
|
||||
}
|
||||
read($fp, $byte, 1) or die "Error reading $fileName";
|
||||
my $output = sprintf("0x%02X", ord($byte));
|
||||
print OUT_FILE $output;
|
||||
|
||||
if ($i != ($fileLen - 1)) {
|
||||
print OUT_FILE ",";
|
||||
}
|
||||
|
||||
if ($j == 10) {
|
||||
$j = 0;
|
||||
print OUT_FILE "\n";
|
||||
}
|
||||
}
|
||||
|
||||
print OUT_FILE "\n";
|
||||
|
||||
close($fp);
|
||||
}
|
@ -1,674 +0,0 @@
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
Version 3, 29 June 2007
|
||||
|
||||
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
Preamble
|
||||
|
||||
The GNU General Public License is a free, copyleft license for
|
||||
software and other kinds of works.
|
||||
|
||||
The licenses for most software and other practical works are designed
|
||||
to take away your freedom to share and change the works. By contrast,
|
||||
the GNU General Public License is intended to guarantee your freedom to
|
||||
share and change all versions of a program--to make sure it remains free
|
||||
software for all its users. We, the Free Software Foundation, use the
|
||||
GNU General Public License for most of our software; it applies also to
|
||||
any other work released this way by its authors. You can apply it to
|
||||
your programs, too.
|
||||
|
||||
When we speak of free software, we are referring to freedom, not
|
||||
price. Our General Public Licenses are designed to make sure that you
|
||||
have the freedom to distribute copies of free software (and charge for
|
||||
them if you wish), that you receive source code or can get it if you
|
||||
want it, that you can change the software or use pieces of it in new
|
||||
free programs, and that you know you can do these things.
|
||||
|
||||
To protect your rights, we need to prevent others from denying you
|
||||
these rights or asking you to surrender the rights. Therefore, you have
|
||||
certain responsibilities if you distribute copies of the software, or if
|
||||
you modify it: responsibilities to respect the freedom of others.
|
||||
|
||||
For example, if you distribute copies of such a program, whether
|
||||
gratis or for a fee, you must pass on to the recipients the same
|
||||
freedoms that you received. You must make sure that they, too, receive
|
||||
or can get the source code. And you must show them these terms so they
|
||||
know their rights.
|
||||
|
||||
Developers that use the GNU GPL protect your rights with two steps:
|
||||
(1) assert copyright on the software, and (2) offer you this License
|
||||
giving you legal permission to copy, distribute and/or modify it.
|
||||
|
||||
For the developers' and authors' protection, the GPL clearly explains
|
||||
that there is no warranty for this free software. For both users' and
|
||||
authors' sake, the GPL requires that modified versions be marked as
|
||||
changed, so that their problems will not be attributed erroneously to
|
||||
authors of previous versions.
|
||||
|
||||
Some devices are designed to deny users access to install or run
|
||||
modified versions of the software inside them, although the manufacturer
|
||||
can do so. This is fundamentally incompatible with the aim of
|
||||
protecting users' freedom to change the software. The systematic
|
||||
pattern of such abuse occurs in the area of products for individuals to
|
||||
use, which is precisely where it is most unacceptable. Therefore, we
|
||||
have designed this version of the GPL to prohibit the practice for those
|
||||
products. If such problems arise substantially in other domains, we
|
||||
stand ready to extend this provision to those domains in future versions
|
||||
of the GPL, as needed to protect the freedom of users.
|
||||
|
||||
Finally, every program is threatened constantly by software patents.
|
||||
States should not allow patents to restrict development and use of
|
||||
software on general-purpose computers, but in those that do, we wish to
|
||||
avoid the special danger that patents applied to a free program could
|
||||
make it effectively proprietary. To prevent this, the GPL assures that
|
||||
patents cannot be used to render the program non-free.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow.
|
||||
|
||||
TERMS AND CONDITIONS
|
||||
|
||||
0. Definitions.
|
||||
|
||||
"This License" refers to version 3 of the GNU General Public License.
|
||||
|
||||
"Copyright" also means copyright-like laws that apply to other kinds of
|
||||
works, such as semiconductor masks.
|
||||
|
||||
"The Program" refers to any copyrightable work licensed under this
|
||||
License. Each licensee is addressed as "you". "Licensees" and
|
||||
"recipients" may be individuals or organizations.
|
||||
|
||||
To "modify" a work means to copy from or adapt all or part of the work
|
||||
in a fashion requiring copyright permission, other than the making of an
|
||||
exact copy. The resulting work is called a "modified version" of the
|
||||
earlier work or a work "based on" the earlier work.
|
||||
|
||||
A "covered work" means either the unmodified Program or a work based
|
||||
on the Program.
|
||||
|
||||
To "propagate" a work means to do anything with it that, without
|
||||
permission, would make you directly or secondarily liable for
|
||||
infringement under applicable copyright law, except executing it on a
|
||||
computer or modifying a private copy. Propagation includes copying,
|
||||
distribution (with or without modification), making available to the
|
||||
public, and in some countries other activities as well.
|
||||
|
||||
To "convey" a work means any kind of propagation that enables other
|
||||
parties to make or receive copies. Mere interaction with a user through
|
||||
a computer network, with no transfer of a copy, is not conveying.
|
||||
|
||||
An interactive user interface displays "Appropriate Legal Notices"
|
||||
to the extent that it includes a convenient and prominently visible
|
||||
feature that (1) displays an appropriate copyright notice, and (2)
|
||||
tells the user that there is no warranty for the work (except to the
|
||||
extent that warranties are provided), that licensees may convey the
|
||||
work under this License, and how to view a copy of this License. If
|
||||
the interface presents a list of user commands or options, such as a
|
||||
menu, a prominent item in the list meets this criterion.
|
||||
|
||||
1. Source Code.
|
||||
|
||||
The "source code" for a work means the preferred form of the work
|
||||
for making modifications to it. "Object code" means any non-source
|
||||
form of a work.
|
||||
|
||||
A "Standard Interface" means an interface that either is an official
|
||||
standard defined by a recognized standards body, or, in the case of
|
||||
interfaces specified for a particular programming language, one that
|
||||
is widely used among developers working in that language.
|
||||
|
||||
The "System Libraries" of an executable work include anything, other
|
||||
than the work as a whole, that (a) is included in the normal form of
|
||||
packaging a Major Component, but which is not part of that Major
|
||||
Component, and (b) serves only to enable use of the work with that
|
||||
Major Component, or to implement a Standard Interface for which an
|
||||
implementation is available to the public in source code form. A
|
||||
"Major Component", in this context, means a major essential component
|
||||
(kernel, window system, and so on) of the specific operating system
|
||||
(if any) on which the executable work runs, or a compiler used to
|
||||
produce the work, or an object code interpreter used to run it.
|
||||
|
||||
The "Corresponding Source" for a work in object code form means all
|
||||
the source code needed to generate, install, and (for an executable
|
||||
work) run the object code and to modify the work, including scripts to
|
||||
control those activities. However, it does not include the work's
|
||||
System Libraries, or general-purpose tools or generally available free
|
||||
programs which are used unmodified in performing those activities but
|
||||
which are not part of the work. For example, Corresponding Source
|
||||
includes interface definition files associated with source files for
|
||||
the work, and the source code for shared libraries and dynamically
|
||||
linked subprograms that the work is specifically designed to require,
|
||||
such as by intimate data communication or control flow between those
|
||||
subprograms and other parts of the work.
|
||||
|
||||
The Corresponding Source need not include anything that users
|
||||
can regenerate automatically from other parts of the Corresponding
|
||||
Source.
|
||||
|
||||
The Corresponding Source for a work in source code form is that
|
||||
same work.
|
||||
|
||||
2. Basic Permissions.
|
||||
|
||||
All rights granted under this License are granted for the term of
|
||||
copyright on the Program, and are irrevocable provided the stated
|
||||
conditions are met. This License explicitly affirms your unlimited
|
||||
permission to run the unmodified Program. The output from running a
|
||||
covered work is covered by this License only if the output, given its
|
||||
content, constitutes a covered work. This License acknowledges your
|
||||
rights of fair use or other equivalent, as provided by copyright law.
|
||||
|
||||
You may make, run and propagate covered works that you do not
|
||||
convey, without conditions so long as your license otherwise remains
|
||||
in force. You may convey covered works to others for the sole purpose
|
||||
of having them make modifications exclusively for you, or provide you
|
||||
with facilities for running those works, provided that you comply with
|
||||
the terms of this License in conveying all material for which you do
|
||||
not control copyright. Those thus making or running the covered works
|
||||
for you must do so exclusively on your behalf, under your direction
|
||||
and control, on terms that prohibit them from making any copies of
|
||||
your copyrighted material outside their relationship with you.
|
||||
|
||||
Conveying under any other circumstances is permitted solely under
|
||||
the conditions stated below. Sublicensing is not allowed; section 10
|
||||
makes it unnecessary.
|
||||
|
||||
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
|
||||
|
||||
No covered work shall be deemed part of an effective technological
|
||||
measure under any applicable law fulfilling obligations under article
|
||||
11 of the WIPO copyright treaty adopted on 20 December 1996, or
|
||||
similar laws prohibiting or restricting circumvention of such
|
||||
measures.
|
||||
|
||||
When you convey a covered work, you waive any legal power to forbid
|
||||
circumvention of technological measures to the extent such circumvention
|
||||
is effected by exercising rights under this License with respect to
|
||||
the covered work, and you disclaim any intention to limit operation or
|
||||
modification of the work as a means of enforcing, against the work's
|
||||
users, your or third parties' legal rights to forbid circumvention of
|
||||
technological measures.
|
||||
|
||||
4. Conveying Verbatim Copies.
|
||||
|
||||
You may convey verbatim copies of the Program's source code as you
|
||||
receive it, in any medium, provided that you conspicuously and
|
||||
appropriately publish on each copy an appropriate copyright notice;
|
||||
keep intact all notices stating that this License and any
|
||||
non-permissive terms added in accord with section 7 apply to the code;
|
||||
keep intact all notices of the absence of any warranty; and give all
|
||||
recipients a copy of this License along with the Program.
|
||||
|
||||
You may charge any price or no price for each copy that you convey,
|
||||
and you may offer support or warranty protection for a fee.
|
||||
|
||||
5. Conveying Modified Source Versions.
|
||||
|
||||
You may convey a work based on the Program, or the modifications to
|
||||
produce it from the Program, in the form of source code under the
|
||||
terms of section 4, provided that you also meet all of these conditions:
|
||||
|
||||
a) The work must carry prominent notices stating that you modified
|
||||
it, and giving a relevant date.
|
||||
|
||||
b) The work must carry prominent notices stating that it is
|
||||
released under this License and any conditions added under section
|
||||
7. This requirement modifies the requirement in section 4 to
|
||||
"keep intact all notices".
|
||||
|
||||
c) You must license the entire work, as a whole, under this
|
||||
License to anyone who comes into possession of a copy. This
|
||||
License will therefore apply, along with any applicable section 7
|
||||
additional terms, to the whole of the work, and all its parts,
|
||||
regardless of how they are packaged. This License gives no
|
||||
permission to license the work in any other way, but it does not
|
||||
invalidate such permission if you have separately received it.
|
||||
|
||||
d) If the work has interactive user interfaces, each must display
|
||||
Appropriate Legal Notices; however, if the Program has interactive
|
||||
interfaces that do not display Appropriate Legal Notices, your
|
||||
work need not make them do so.
|
||||
|
||||
A compilation of a covered work with other separate and independent
|
||||
works, which are not by their nature extensions of the covered work,
|
||||
and which are not combined with it such as to form a larger program,
|
||||
in or on a volume of a storage or distribution medium, is called an
|
||||
"aggregate" if the compilation and its resulting copyright are not
|
||||
used to limit the access or legal rights of the compilation's users
|
||||
beyond what the individual works permit. Inclusion of a covered work
|
||||
in an aggregate does not cause this License to apply to the other
|
||||
parts of the aggregate.
|
||||
|
||||
6. Conveying Non-Source Forms.
|
||||
|
||||
You may convey a covered work in object code form under the terms
|
||||
of sections 4 and 5, provided that you also convey the
|
||||
machine-readable Corresponding Source under the terms of this License,
|
||||
in one of these ways:
|
||||
|
||||
a) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by the
|
||||
Corresponding Source fixed on a durable physical medium
|
||||
customarily used for software interchange.
|
||||
|
||||
b) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by a
|
||||
written offer, valid for at least three years and valid for as
|
||||
long as you offer spare parts or customer support for that product
|
||||
model, to give anyone who possesses the object code either (1) a
|
||||
copy of the Corresponding Source for all the software in the
|
||||
product that is covered by this License, on a durable physical
|
||||
medium customarily used for software interchange, for a price no
|
||||
more than your reasonable cost of physically performing this
|
||||
conveying of source, or (2) access to copy the
|
||||
Corresponding Source from a network server at no charge.
|
||||
|
||||
c) Convey individual copies of the object code with a copy of the
|
||||
written offer to provide the Corresponding Source. This
|
||||
alternative is allowed only occasionally and noncommercially, and
|
||||
only if you received the object code with such an offer, in accord
|
||||
with subsection 6b.
|
||||
|
||||
d) Convey the object code by offering access from a designated
|
||||
place (gratis or for a charge), and offer equivalent access to the
|
||||
Corresponding Source in the same way through the same place at no
|
||||
further charge. You need not require recipients to copy the
|
||||
Corresponding Source along with the object code. If the place to
|
||||
copy the object code is a network server, the Corresponding Source
|
||||
may be on a different server (operated by you or a third party)
|
||||
that supports equivalent copying facilities, provided you maintain
|
||||
clear directions next to the object code saying where to find the
|
||||
Corresponding Source. Regardless of what server hosts the
|
||||
Corresponding Source, you remain obligated to ensure that it is
|
||||
available for as long as needed to satisfy these requirements.
|
||||
|
||||
e) Convey the object code using peer-to-peer transmission, provided
|
||||
you inform other peers where the object code and Corresponding
|
||||
Source of the work are being offered to the general public at no
|
||||
charge under subsection 6d.
|
||||
|
||||
A separable portion of the object code, whose source code is excluded
|
||||
from the Corresponding Source as a System Library, need not be
|
||||
included in conveying the object code work.
|
||||
|
||||
A "User Product" is either (1) a "consumer product", which means any
|
||||
tangible personal property which is normally used for personal, family,
|
||||
or household purposes, or (2) anything designed or sold for incorporation
|
||||
into a dwelling. In determining whether a product is a consumer product,
|
||||
doubtful cases shall be resolved in favor of coverage. For a particular
|
||||
product received by a particular user, "normally used" refers to a
|
||||
typical or common use of that class of product, regardless of the status
|
||||
of the particular user or of the way in which the particular user
|
||||
actually uses, or expects or is expected to use, the product. A product
|
||||
is a consumer product regardless of whether the product has substantial
|
||||
commercial, industrial or non-consumer uses, unless such uses represent
|
||||
the only significant mode of use of the product.
|
||||
|
||||
"Installation Information" for a User Product means any methods,
|
||||
procedures, authorization keys, or other information required to install
|
||||
and execute modified versions of a covered work in that User Product from
|
||||
a modified version of its Corresponding Source. The information must
|
||||
suffice to ensure that the continued functioning of the modified object
|
||||
code is in no case prevented or interfered with solely because
|
||||
modification has been made.
|
||||
|
||||
If you convey an object code work under this section in, or with, or
|
||||
specifically for use in, a User Product, and the conveying occurs as
|
||||
part of a transaction in which the right of possession and use of the
|
||||
User Product is transferred to the recipient in perpetuity or for a
|
||||
fixed term (regardless of how the transaction is characterized), the
|
||||
Corresponding Source conveyed under this section must be accompanied
|
||||
by the Installation Information. But this requirement does not apply
|
||||
if neither you nor any third party retains the ability to install
|
||||
modified object code on the User Product (for example, the work has
|
||||
been installed in ROM).
|
||||
|
||||
The requirement to provide Installation Information does not include a
|
||||
requirement to continue to provide support service, warranty, or updates
|
||||
for a work that has been modified or installed by the recipient, or for
|
||||
the User Product in which it has been modified or installed. Access to a
|
||||
network may be denied when the modification itself materially and
|
||||
adversely affects the operation of the network or violates the rules and
|
||||
protocols for communication across the network.
|
||||
|
||||
Corresponding Source conveyed, and Installation Information provided,
|
||||
in accord with this section must be in a format that is publicly
|
||||
documented (and with an implementation available to the public in
|
||||
source code form), and must require no special password or key for
|
||||
unpacking, reading or copying.
|
||||
|
||||
7. Additional Terms.
|
||||
|
||||
"Additional permissions" are terms that supplement the terms of this
|
||||
License by making exceptions from one or more of its conditions.
|
||||
Additional permissions that are applicable to the entire Program shall
|
||||
be treated as though they were included in this License, to the extent
|
||||
that they are valid under applicable law. If additional permissions
|
||||
apply only to part of the Program, that part may be used separately
|
||||
under those permissions, but the entire Program remains governed by
|
||||
this License without regard to the additional permissions.
|
||||
|
||||
When you convey a copy of a covered work, you may at your option
|
||||
remove any additional permissions from that copy, or from any part of
|
||||
it. (Additional permissions may be written to require their own
|
||||
removal in certain cases when you modify the work.) You may place
|
||||
additional permissions on material, added by you to a covered work,
|
||||
for which you have or can give appropriate copyright permission.
|
||||
|
||||
Notwithstanding any other provision of this License, for material you
|
||||
add to a covered work, you may (if authorized by the copyright holders of
|
||||
that material) supplement the terms of this License with terms:
|
||||
|
||||
a) Disclaiming warranty or limiting liability differently from the
|
||||
terms of sections 15 and 16 of this License; or
|
||||
|
||||
b) Requiring preservation of specified reasonable legal notices or
|
||||
author attributions in that material or in the Appropriate Legal
|
||||
Notices displayed by works containing it; or
|
||||
|
||||
c) Prohibiting misrepresentation of the origin of that material, or
|
||||
requiring that modified versions of such material be marked in
|
||||
reasonable ways as different from the original version; or
|
||||
|
||||
d) Limiting the use for publicity purposes of names of licensors or
|
||||
authors of the material; or
|
||||
|
||||
e) Declining to grant rights under trademark law for use of some
|
||||
trade names, trademarks, or service marks; or
|
||||
|
||||
f) Requiring indemnification of licensors and authors of that
|
||||
material by anyone who conveys the material (or modified versions of
|
||||
it) with contractual assumptions of liability to the recipient, for
|
||||
any liability that these contractual assumptions directly impose on
|
||||
those licensors and authors.
|
||||
|
||||
All other non-permissive additional terms are considered "further
|
||||
restrictions" within the meaning of section 10. If the Program as you
|
||||
received it, or any part of it, contains a notice stating that it is
|
||||
governed by this License along with a term that is a further
|
||||
restriction, you may remove that term. If a license document contains
|
||||
a further restriction but permits relicensing or conveying under this
|
||||
License, you may add to a covered work material governed by the terms
|
||||
of that license document, provided that the further restriction does
|
||||
not survive such relicensing or conveying.
|
||||
|
||||
If you add terms to a covered work in accord with this section, you
|
||||
must place, in the relevant source files, a statement of the
|
||||
additional terms that apply to those files, or a notice indicating
|
||||
where to find the applicable terms.
|
||||
|
||||
Additional terms, permissive or non-permissive, may be stated in the
|
||||
form of a separately written license, or stated as exceptions;
|
||||
the above requirements apply either way.
|
||||
|
||||
8. Termination.
|
||||
|
||||
You may not propagate or modify a covered work except as expressly
|
||||
provided under this License. Any attempt otherwise to propagate or
|
||||
modify it is void, and will automatically terminate your rights under
|
||||
this License (including any patent licenses granted under the third
|
||||
paragraph of section 11).
|
||||
|
||||
However, if you cease all violation of this License, then your
|
||||
license from a particular copyright holder is reinstated (a)
|
||||
provisionally, unless and until the copyright holder explicitly and
|
||||
finally terminates your license, and (b) permanently, if the copyright
|
||||
holder fails to notify you of the violation by some reasonable means
|
||||
prior to 60 days after the cessation.
|
||||
|
||||
Moreover, your license from a particular copyright holder is
|
||||
reinstated permanently if the copyright holder notifies you of the
|
||||
violation by some reasonable means, this is the first time you have
|
||||
received notice of violation of this License (for any work) from that
|
||||
copyright holder, and you cure the violation prior to 30 days after
|
||||
your receipt of the notice.
|
||||
|
||||
Termination of your rights under this section does not terminate the
|
||||
licenses of parties who have received copies or rights from you under
|
||||
this License. If your rights have been terminated and not permanently
|
||||
reinstated, you do not qualify to receive new licenses for the same
|
||||
material under section 10.
|
||||
|
||||
9. Acceptance Not Required for Having Copies.
|
||||
|
||||
You are not required to accept this License in order to receive or
|
||||
run a copy of the Program. Ancillary propagation of a covered work
|
||||
occurring solely as a consequence of using peer-to-peer transmission
|
||||
to receive a copy likewise does not require acceptance. However,
|
||||
nothing other than this License grants you permission to propagate or
|
||||
modify any covered work. These actions infringe copyright if you do
|
||||
not accept this License. Therefore, by modifying or propagating a
|
||||
covered work, you indicate your acceptance of this License to do so.
|
||||
|
||||
10. Automatic Licensing of Downstream Recipients.
|
||||
|
||||
Each time you convey a covered work, the recipient automatically
|
||||
receives a license from the original licensors, to run, modify and
|
||||
propagate that work, subject to this License. You are not responsible
|
||||
for enforcing compliance by third parties with this License.
|
||||
|
||||
An "entity transaction" is a transaction transferring control of an
|
||||
organization, or substantially all assets of one, or subdividing an
|
||||
organization, or merging organizations. If propagation of a covered
|
||||
work results from an entity transaction, each party to that
|
||||
transaction who receives a copy of the work also receives whatever
|
||||
licenses to the work the party's predecessor in interest had or could
|
||||
give under the previous paragraph, plus a right to possession of the
|
||||
Corresponding Source of the work from the predecessor in interest, if
|
||||
the predecessor has it or can get it with reasonable efforts.
|
||||
|
||||
You may not impose any further restrictions on the exercise of the
|
||||
rights granted or affirmed under this License. For example, you may
|
||||
not impose a license fee, royalty, or other charge for exercise of
|
||||
rights granted under this License, and you may not initiate litigation
|
||||
(including a cross-claim or counterclaim in a lawsuit) alleging that
|
||||
any patent claim is infringed by making, using, selling, offering for
|
||||
sale, or importing the Program or any portion of it.
|
||||
|
||||
11. Patents.
|
||||
|
||||
A "contributor" is a copyright holder who authorizes use under this
|
||||
License of the Program or a work on which the Program is based. The
|
||||
work thus licensed is called the contributor's "contributor version".
|
||||
|
||||
A contributor's "essential patent claims" are all patent claims
|
||||
owned or controlled by the contributor, whether already acquired or
|
||||
hereafter acquired, that would be infringed by some manner, permitted
|
||||
by this License, of making, using, or selling its contributor version,
|
||||
but do not include claims that would be infringed only as a
|
||||
consequence of further modification of the contributor version. For
|
||||
purposes of this definition, "control" includes the right to grant
|
||||
patent sublicenses in a manner consistent with the requirements of
|
||||
this License.
|
||||
|
||||
Each contributor grants you a non-exclusive, worldwide, royalty-free
|
||||
patent license under the contributor's essential patent claims, to
|
||||
make, use, sell, offer for sale, import and otherwise run, modify and
|
||||
propagate the contents of its contributor version.
|
||||
|
||||
In the following three paragraphs, a "patent license" is any express
|
||||
agreement or commitment, however denominated, not to enforce a patent
|
||||
(such as an express permission to practice a patent or covenant not to
|
||||
sue for patent infringement). To "grant" such a patent license to a
|
||||
party means to make such an agreement or commitment not to enforce a
|
||||
patent against the party.
|
||||
|
||||
If you convey a covered work, knowingly relying on a patent license,
|
||||
and the Corresponding Source of the work is not available for anyone
|
||||
to copy, free of charge and under the terms of this License, through a
|
||||
publicly available network server or other readily accessible means,
|
||||
then you must either (1) cause the Corresponding Source to be so
|
||||
available, or (2) arrange to deprive yourself of the benefit of the
|
||||
patent license for this particular work, or (3) arrange, in a manner
|
||||
consistent with the requirements of this License, to extend the patent
|
||||
license to downstream recipients. "Knowingly relying" means you have
|
||||
actual knowledge that, but for the patent license, your conveying the
|
||||
covered work in a country, or your recipient's use of the covered work
|
||||
in a country, would infringe one or more identifiable patents in that
|
||||
country that you have reason to believe are valid.
|
||||
|
||||
If, pursuant to or in connection with a single transaction or
|
||||
arrangement, you convey, or propagate by procuring conveyance of, a
|
||||
covered work, and grant a patent license to some of the parties
|
||||
receiving the covered work authorizing them to use, propagate, modify
|
||||
or convey a specific copy of the covered work, then the patent license
|
||||
you grant is automatically extended to all recipients of the covered
|
||||
work and works based on it.
|
||||
|
||||
A patent license is "discriminatory" if it does not include within
|
||||
the scope of its coverage, prohibits the exercise of, or is
|
||||
conditioned on the non-exercise of one or more of the rights that are
|
||||
specifically granted under this License. You may not convey a covered
|
||||
work if you are a party to an arrangement with a third party that is
|
||||
in the business of distributing software, under which you make payment
|
||||
to the third party based on the extent of your activity of conveying
|
||||
the work, and under which the third party grants, to any of the
|
||||
parties who would receive the covered work from you, a discriminatory
|
||||
patent license (a) in connection with copies of the covered work
|
||||
conveyed by you (or copies made from those copies), or (b) primarily
|
||||
for and in connection with specific products or compilations that
|
||||
contain the covered work, unless you entered into that arrangement,
|
||||
or that patent license was granted, prior to 28 March 2007.
|
||||
|
||||
Nothing in this License shall be construed as excluding or limiting
|
||||
any implied license or other defenses to infringement that may
|
||||
otherwise be available to you under applicable patent law.
|
||||
|
||||
12. No Surrender of Others' Freedom.
|
||||
|
||||
If conditions are imposed on you (whether by court order, agreement or
|
||||
otherwise) that contradict the conditions of this License, they do not
|
||||
excuse you from the conditions of this License. If you cannot convey a
|
||||
covered work so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you may
|
||||
not convey it at all. For example, if you agree to terms that obligate you
|
||||
to collect a royalty for further conveying from those to whom you convey
|
||||
the Program, the only way you could satisfy both those terms and this
|
||||
License would be to refrain entirely from conveying the Program.
|
||||
|
||||
13. Use with the GNU Affero General Public License.
|
||||
|
||||
Notwithstanding any other provision of this License, you have
|
||||
permission to link or combine any covered work with a work licensed
|
||||
under version 3 of the GNU Affero General Public License into a single
|
||||
combined work, and to convey the resulting work. The terms of this
|
||||
License will continue to apply to the part which is the covered work,
|
||||
but the special requirements of the GNU Affero General Public License,
|
||||
section 13, concerning interaction through a network will apply to the
|
||||
combination as such.
|
||||
|
||||
14. Revised Versions of this License.
|
||||
|
||||
The Free Software Foundation may publish revised and/or new versions of
|
||||
the GNU General Public License from time to time. Such new versions will
|
||||
be similar in spirit to the present version, but may differ in detail to
|
||||
address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the
|
||||
Program specifies that a certain numbered version of the GNU General
|
||||
Public License "or any later version" applies to it, you have the
|
||||
option of following the terms and conditions either of that numbered
|
||||
version or of any later version published by the Free Software
|
||||
Foundation. If the Program does not specify a version number of the
|
||||
GNU General Public License, you may choose any version ever published
|
||||
by the Free Software Foundation.
|
||||
|
||||
If the Program specifies that a proxy can decide which future
|
||||
versions of the GNU General Public License can be used, that proxy's
|
||||
public statement of acceptance of a version permanently authorizes you
|
||||
to choose that version for the Program.
|
||||
|
||||
Later license versions may give you additional or different
|
||||
permissions. However, no additional obligations are imposed on any
|
||||
author or copyright holder as a result of your choosing to follow a
|
||||
later version.
|
||||
|
||||
15. Disclaimer of Warranty.
|
||||
|
||||
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
|
||||
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
|
||||
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
|
||||
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
|
||||
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
|
||||
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
|
||||
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
||||
|
||||
16. Limitation of Liability.
|
||||
|
||||
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
|
||||
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
|
||||
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
|
||||
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
|
||||
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
|
||||
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
|
||||
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
|
||||
SUCH DAMAGES.
|
||||
|
||||
17. Interpretation of Sections 15 and 16.
|
||||
|
||||
If the disclaimer of warranty and limitation of liability provided
|
||||
above cannot be given local legal effect according to their terms,
|
||||
reviewing courts shall apply local law that most closely approximates
|
||||
an absolute waiver of all civil liability in connection with the
|
||||
Program, unless a warranty or assumption of liability accompanies a
|
||||
copy of the Program in return for a fee.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
How to Apply These Terms to Your New Programs
|
||||
|
||||
If you develop a new program, and you want it to be of the greatest
|
||||
possible use to the public, the best way to achieve this is to make it
|
||||
free software which everyone can redistribute and change under these terms.
|
||||
|
||||
To do so, attach the following notices to the program. It is safest
|
||||
to attach them to the start of each source file to most effectively
|
||||
state the exclusion of warranty; and each file should have at least
|
||||
the "copyright" line and a pointer to where the full notice is found.
|
||||
|
||||
<one line to give the program's name and a brief idea of what it does.>
|
||||
Copyright (C) <year> <name of author>
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
If the program does terminal interaction, make it output a short
|
||||
notice like this when it starts in an interactive mode:
|
||||
|
||||
<program> Copyright (C) <year> <name of author>
|
||||
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||
This is free software, and you are welcome to redistribute it
|
||||
under certain conditions; type `show c' for details.
|
||||
|
||||
The hypothetical commands `show w' and `show c' should show the appropriate
|
||||
parts of the General Public License. Of course, your program's commands
|
||||
might be different; for a GUI interface, you would use an "about box".
|
||||
|
||||
You should also get your employer (if you work as a programmer) or school,
|
||||
if any, to sign a "copyright disclaimer" for the program, if necessary.
|
||||
For more information on this, and how to apply and follow the GNU GPL, see
|
||||
<http://www.gnu.org/licenses/>.
|
||||
|
||||
The GNU General Public License does not permit incorporating your program
|
||||
into proprietary programs. If your program is a subroutine library, you
|
||||
may consider it more useful to permit linking proprietary applications with
|
||||
the library. If this is what you want to do, use the GNU Lesser General
|
||||
Public License instead of this License. But first, please read
|
||||
<http://www.gnu.org/philosophy/why-not-lgpl.html>.
|
@ -1,89 +0,0 @@
|
||||
/* echoclient.c */
|
||||
|
||||
#include "openssl/ssl.h"
|
||||
#include "../test.h"
|
||||
|
||||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
SOCKET_T sockfd = 0;
|
||||
|
||||
FILE* fin = stdin;
|
||||
FILE* fout = stdout;
|
||||
|
||||
int inCreated = 0;
|
||||
int outCreated = 0;
|
||||
|
||||
char send[1024];
|
||||
char reply[1024];
|
||||
|
||||
SSL_METHOD* method = 0;
|
||||
SSL_CTX* ctx = 0;
|
||||
SSL* ssl = 0;
|
||||
|
||||
#ifdef _WIN32
|
||||
WSADATA wsd;
|
||||
WSAStartup(0x0002, &wsd);
|
||||
#endif
|
||||
|
||||
if (argc >= 2) {
|
||||
fin = fopen(argv[1], "r");
|
||||
inCreated = 1;
|
||||
}
|
||||
if (argc >= 3) {
|
||||
fout = fopen(argv[2], "w");
|
||||
outCreated = 1;
|
||||
}
|
||||
|
||||
if (!fin) err_sys("can't open input file");
|
||||
if (!fout) err_sys("can't open output file");
|
||||
|
||||
tcp_connect(&sockfd);
|
||||
|
||||
method = SSLv3_client_method();
|
||||
ctx = SSL_CTX_new(method);
|
||||
|
||||
if (SSL_CTX_load_verify_locations(ctx, caCert, 0) != SSL_SUCCESS)
|
||||
err_sys("can't load ca file");
|
||||
|
||||
ssl = SSL_new(ctx);
|
||||
|
||||
if (SSL_set_fd(ssl, sockfd) != SSL_SUCCESS)
|
||||
err_sys("can't set ssl fd");
|
||||
|
||||
if (SSL_connect(ssl) != SSL_SUCCESS) err_sys("SSL_connect failed");
|
||||
|
||||
while (fgets(send, sizeof(send), fin)) {
|
||||
|
||||
int sendSz = strlen(send) + 1;
|
||||
|
||||
if (SSL_write(ssl, send, sendSz) != sendSz)
|
||||
err_sys("SSL_write failed");
|
||||
|
||||
if (strncmp(send, "quit", 4) == 0) {
|
||||
fputs("sending server shutdown command: quit!\n", fout);
|
||||
break;
|
||||
}
|
||||
|
||||
if (SSL_read(ssl, reply, sizeof(reply)) > 0)
|
||||
fputs(reply, fout);
|
||||
}
|
||||
|
||||
SSL_shutdown(ssl);
|
||||
SSL_free(ssl);
|
||||
SSL_CTX_free(ctx);
|
||||
|
||||
fflush(fout);
|
||||
if (inCreated) fclose(fin);
|
||||
if (outCreated) fclose(fout);
|
||||
|
||||
#ifdef _WIN32
|
||||
closesocket(sockfd);
|
||||
#else
|
||||
close(sockfd);
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -1,2 +0,0 @@
|
||||
quit
|
||||
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -1,533 +0,0 @@
|
||||
# vim:ft=automake
|
||||
# included from Top Level Makefile.am
|
||||
# All paths should be given relative to the root
|
||||
|
||||
lib_LTLIBRARIES+= src/libwolfssl.la
|
||||
src_libwolfssl_la_SOURCES =
|
||||
src_libwolfssl_la_LDFLAGS = ${AM_LDFLAGS} -no-undefined -version-info ${WOLFSSL_LIBRARY_VERSION}
|
||||
src_libwolfssl_la_LIBADD = $(LIBM) $(LIB_ADD) $(LIB_STATIC_ADD)
|
||||
src_libwolfssl_la_CFLAGS = -DBUILDING_WOLFSSL $(AM_CFLAGS)
|
||||
src_libwolfssl_la_CPPFLAGS = -DBUILDING_WOLFSSL $(AM_CPPFLAGS)
|
||||
|
||||
# install the packaged IPP libraries
|
||||
if BUILD_FAST_RSA
|
||||
|
||||
# Link needed IPP libraries
|
||||
noinst_SCRIPTS+=IPP_links
|
||||
IPP_links:
|
||||
@$(IPPLINK)
|
||||
|
||||
ippdir = $(libdir)
|
||||
ipp_DATA = $(IPPLIBS)
|
||||
|
||||
include_HEADERS+=$(IPPHEADERS)
|
||||
endif # BUILD_FAST_RSA
|
||||
|
||||
if BUILD_FIPS
|
||||
|
||||
if BUILD_FIPS_V1
|
||||
# fips first file
|
||||
src_libwolfssl_la_SOURCES += ctaocrypt/src/wolfcrypt_first.c
|
||||
|
||||
src_libwolfssl_la_SOURCES += \
|
||||
ctaocrypt/src/hmac.c \
|
||||
ctaocrypt/src/random.c \
|
||||
ctaocrypt/src/sha256.c
|
||||
|
||||
if BUILD_RSA
|
||||
src_libwolfssl_la_SOURCES += ctaocrypt/src/rsa.c
|
||||
endif
|
||||
|
||||
if BUILD_AES
|
||||
src_libwolfssl_la_SOURCES += ctaocrypt/src/aes.c
|
||||
endif
|
||||
|
||||
if BUILD_DES3
|
||||
src_libwolfssl_la_SOURCES += ctaocrypt/src/des3.c
|
||||
endif
|
||||
|
||||
if BUILD_SHA
|
||||
src_libwolfssl_la_SOURCES += ctaocrypt/src/sha.c
|
||||
endif
|
||||
|
||||
if BUILD_SHA512
|
||||
src_libwolfssl_la_SOURCES += ctaocrypt/src/sha512.c
|
||||
endif
|
||||
|
||||
src_libwolfssl_la_SOURCES += ctaocrypt/src/fips.c
|
||||
src_libwolfssl_la_SOURCES += ctaocrypt/src/fips_test.c
|
||||
|
||||
# fips last file
|
||||
src_libwolfssl_la_SOURCES += ctaocrypt/src/wolfcrypt_last.c
|
||||
endif
|
||||
|
||||
if BUILD_FIPS_V2
|
||||
# FIPSv2 first file
|
||||
src_libwolfssl_la_SOURCES += \
|
||||
wolfcrypt/src/wolfcrypt_first.c
|
||||
|
||||
src_libwolfssl_la_SOURCES += \
|
||||
wolfcrypt/src/hmac.c \
|
||||
wolfcrypt/src/random.c \
|
||||
wolfcrypt/src/sha256.c
|
||||
|
||||
if BUILD_RSA
|
||||
src_libwolfssl_la_SOURCES += wolfcrypt/src/rsa.c
|
||||
endif
|
||||
|
||||
if BUILD_ECC
|
||||
src_libwolfssl_la_SOURCES += wolfcrypt/src/ecc.c
|
||||
endif
|
||||
|
||||
if BUILD_AES
|
||||
src_libwolfssl_la_SOURCES += wolfcrypt/src/aes.c
|
||||
endif
|
||||
|
||||
if BUILD_AESNI
|
||||
src_libwolfssl_la_SOURCES += wolfcrypt/src/aes_asm.S
|
||||
if BUILD_INTELASM
|
||||
src_libwolfssl_la_SOURCES += wolfcrypt/src/aes_gcm_asm.S
|
||||
endif
|
||||
endif
|
||||
|
||||
if BUILD_DES3
|
||||
src_libwolfssl_la_SOURCES += wolfcrypt/src/des3.c
|
||||
endif
|
||||
|
||||
if BUILD_SHA
|
||||
src_libwolfssl_la_SOURCES += wolfcrypt/src/sha.c
|
||||
if BUILD_INTELASM
|
||||
src_libwolfssl_la_SOURCES += wolfcrypt/src/sha256_asm.S
|
||||
endif
|
||||
endif
|
||||
|
||||
if BUILD_SHA512
|
||||
src_libwolfssl_la_SOURCES += wolfcrypt/src/sha512.c
|
||||
if BUILD_INTELASM
|
||||
src_libwolfssl_la_SOURCES += wolfcrypt/src/sha512_asm.S
|
||||
endif
|
||||
endif
|
||||
|
||||
if BUILD_SHA3
|
||||
src_libwolfssl_la_SOURCES += wolfcrypt/src/sha3.c
|
||||
endif
|
||||
|
||||
if BUILD_DH
|
||||
src_libwolfssl_la_SOURCES += wolfcrypt/src/dh.c
|
||||
endif
|
||||
|
||||
if BUILD_CMAC
|
||||
src_libwolfssl_la_SOURCES += wolfcrypt/src/cmac.c
|
||||
endif
|
||||
|
||||
src_libwolfssl_la_SOURCES += wolfcrypt/src/fips.c \
|
||||
wolfcrypt/src/fips_test.c
|
||||
|
||||
# fips last file
|
||||
src_libwolfssl_la_SOURCES += wolfcrypt/src/wolfcrypt_last.c
|
||||
endif
|
||||
|
||||
if BUILD_FIPS_RAND
|
||||
src_libwolfssl_la_SOURCES += \
|
||||
wolfcrypt/src/wolfcrypt_first.c \
|
||||
wolfcrypt/src/hmac.c \
|
||||
wolfcrypt/src/random.c \
|
||||
wolfcrypt/src/sha256.c \
|
||||
wolfcrypt/src/sha256_asm.S \
|
||||
wolfcrypt/src/fips.c \
|
||||
wolfcrypt/src/fips_test.c \
|
||||
wolfcrypt/src/wolfcrypt_last.c
|
||||
endif BUILD_FIPS_RAND
|
||||
|
||||
endif BUILD_FIPS
|
||||
|
||||
# For wolfRand, exclude everything else.
|
||||
if !BUILD_FIPS_RAND
|
||||
|
||||
# For FIPSV2, exclude the wolfCrypt files included above.
|
||||
# For wolfRand, exclude just a couple files.
|
||||
# For old FIPS, keep the wolfCrypt versions of the
|
||||
# CtaoCrypt files included above.
|
||||
if !BUILD_FIPS_V2
|
||||
src_libwolfssl_la_SOURCES += wolfcrypt/src/hmac.c
|
||||
endif
|
||||
|
||||
# CAVP self test
|
||||
if BUILD_SELFTEST
|
||||
src_libwolfssl_la_SOURCES += wolfcrypt/src/selftest.c
|
||||
endif
|
||||
|
||||
endif !BUILD_FIPS_RAND
|
||||
|
||||
src_libwolfssl_la_SOURCES += \
|
||||
wolfcrypt/src/hash.c \
|
||||
wolfcrypt/src/cpuid.c
|
||||
|
||||
if !BUILD_FIPS_RAND
|
||||
|
||||
if !BUILD_FIPS_V2
|
||||
if BUILD_RNG
|
||||
src_libwolfssl_la_SOURCES += wolfcrypt/src/random.c
|
||||
endif
|
||||
endif
|
||||
|
||||
if !BUILD_FIPS_V2
|
||||
if BUILD_ARMASM
|
||||
src_libwolfssl_la_SOURCES += wolfcrypt/src/port/arm/armv8-sha256.c
|
||||
else
|
||||
src_libwolfssl_la_SOURCES += wolfcrypt/src/sha256.c
|
||||
if BUILD_INTELASM
|
||||
src_libwolfssl_la_SOURCES += wolfcrypt/src/sha256_asm.S
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
|
||||
if BUILD_AFALG
|
||||
src_libwolfssl_la_SOURCES += wolfcrypt/src/port/af_alg/afalg_hash.c
|
||||
endif
|
||||
|
||||
if BUILD_WOLFEVENT
|
||||
src_libwolfssl_la_SOURCES += wolfcrypt/src/wolfevent.c
|
||||
endif
|
||||
|
||||
if BUILD_ASYNCCRYPT
|
||||
src_libwolfssl_la_SOURCES += wolfcrypt/src/async.c
|
||||
endif
|
||||
|
||||
if !BUILD_USER_RSA
|
||||
if BUILD_RSA
|
||||
if BUILD_FAST_RSA
|
||||
src_libwolfssl_la_SOURCES += wolfcrypt/user-crypto/src/rsa.c
|
||||
else
|
||||
if !BUILD_FIPS_V2
|
||||
src_libwolfssl_la_SOURCES += wolfcrypt/src/rsa.c
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
|
||||
if BUILD_SP
|
||||
if BUILD_SP_C
|
||||
src_libwolfssl_la_SOURCES += wolfcrypt/src/sp_c32.c
|
||||
src_libwolfssl_la_SOURCES += wolfcrypt/src/sp_c64.c
|
||||
endif
|
||||
if BUILD_SP_X86_64
|
||||
src_libwolfssl_la_SOURCES += wolfcrypt/src/sp_x86_64.c
|
||||
src_libwolfssl_la_SOURCES += wolfcrypt/src/sp_x86_64_asm.S
|
||||
endif
|
||||
if !BUILD_FIPS_V2
|
||||
if BUILD_SP_ARM32
|
||||
src_libwolfssl_la_SOURCES += wolfcrypt/src/sp_arm32.c
|
||||
endif
|
||||
endif
|
||||
if BUILD_SP_ARM_THUMB
|
||||
src_libwolfssl_la_SOURCES += wolfcrypt/src/sp_armthumb.c
|
||||
endif
|
||||
if BUILD_SP_ARM64
|
||||
src_libwolfssl_la_SOURCES += wolfcrypt/src/sp_arm64.c
|
||||
endif
|
||||
if BUILD_SP_INT
|
||||
src_libwolfssl_la_SOURCES += wolfcrypt/src/sp_int.c
|
||||
endif
|
||||
if BUILD_SP_ARM_CORTEX
|
||||
src_libwolfssl_la_SOURCES += wolfcrypt/src/sp_cortexm.c
|
||||
endif
|
||||
endif
|
||||
|
||||
if !BUILD_FIPS_V2
|
||||
if BUILD_AES
|
||||
src_libwolfssl_la_SOURCES += wolfcrypt/src/aes.c
|
||||
if BUILD_ARMASM
|
||||
src_libwolfssl_la_SOURCES += wolfcrypt/src/port/arm/armv8-aes.c
|
||||
endif
|
||||
if BUILD_AFALG
|
||||
src_libwolfssl_la_SOURCES += wolfcrypt/src/port/af_alg/afalg_aes.c
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
|
||||
if !BUILD_FIPS_V2
|
||||
if BUILD_CMAC
|
||||
src_libwolfssl_la_SOURCES += wolfcrypt/src/cmac.c
|
||||
endif
|
||||
endif
|
||||
|
||||
if !BUILD_FIPS_V2
|
||||
if BUILD_DES3
|
||||
src_libwolfssl_la_SOURCES += wolfcrypt/src/des3.c
|
||||
endif
|
||||
endif
|
||||
|
||||
if !BUILD_FIPS_V2
|
||||
if BUILD_SHA
|
||||
src_libwolfssl_la_SOURCES += wolfcrypt/src/sha.c
|
||||
endif
|
||||
endif
|
||||
|
||||
if !BUILD_FIPS_V2
|
||||
if BUILD_SHA512
|
||||
if BUILD_ARMASM
|
||||
src_libwolfssl_la_SOURCES += wolfcrypt/src/port/arm/armv8-sha512.c
|
||||
src_libwolfssl_la_SOURCES += wolfcrypt/src/port/arm/armv8-sha512-asm.S
|
||||
src_libwolfssl_la_SOURCES += wolfcrypt/src/port/arm/armv8-32-sha512-asm.S
|
||||
else
|
||||
src_libwolfssl_la_SOURCES += wolfcrypt/src/sha512.c
|
||||
if BUILD_INTELASM
|
||||
src_libwolfssl_la_SOURCES += wolfcrypt/src/sha512_asm.S
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
|
||||
if !BUILD_FIPS_V2
|
||||
if BUILD_SHA3
|
||||
src_libwolfssl_la_SOURCES += wolfcrypt/src/sha3.c
|
||||
endif
|
||||
endif
|
||||
|
||||
|
||||
endif !BUILD_FIPS_RAND
|
||||
|
||||
src_libwolfssl_la_SOURCES += \
|
||||
wolfcrypt/src/logging.c \
|
||||
wolfcrypt/src/wc_port.c \
|
||||
wolfcrypt/src/error.c
|
||||
|
||||
if !BUILD_FIPS_RAND
|
||||
src_libwolfssl_la_SOURCES += \
|
||||
wolfcrypt/src/wc_encrypt.c \
|
||||
wolfcrypt/src/signature.c \
|
||||
wolfcrypt/src/wolfmath.c
|
||||
endif !BUILD_FIPS_RAND
|
||||
|
||||
if BUILD_MEMORY
|
||||
src_libwolfssl_la_SOURCES += wolfcrypt/src/memory.c
|
||||
endif
|
||||
|
||||
if !BUILD_FIPS_RAND
|
||||
if !BUILD_FIPS_V2
|
||||
if BUILD_DH
|
||||
src_libwolfssl_la_SOURCES += wolfcrypt/src/dh.c
|
||||
endif
|
||||
endif
|
||||
|
||||
if BUILD_ASN
|
||||
src_libwolfssl_la_SOURCES += wolfcrypt/src/asn.c
|
||||
endif
|
||||
|
||||
endif !BUILD_FIPS_RAND
|
||||
|
||||
if BUILD_CODING
|
||||
src_libwolfssl_la_SOURCES += wolfcrypt/src/coding.c
|
||||
endif
|
||||
|
||||
if !BUILD_FIPS_RAND
|
||||
|
||||
if BUILD_POLY1305
|
||||
if BUILD_ARMASM
|
||||
src_libwolfssl_la_SOURCES += wolfcrypt/src/port/arm/armv8-poly1305.c
|
||||
endif
|
||||
src_libwolfssl_la_SOURCES += wolfcrypt/src/poly1305.c
|
||||
if BUILD_INTELASM
|
||||
src_libwolfssl_la_SOURCES += wolfcrypt/src/poly1305_asm.S
|
||||
endif
|
||||
endif
|
||||
|
||||
if BUILD_RC4
|
||||
src_libwolfssl_la_SOURCES += wolfcrypt/src/arc4.c
|
||||
endif
|
||||
|
||||
if BUILD_MD4
|
||||
src_libwolfssl_la_SOURCES += wolfcrypt/src/md4.c
|
||||
endif
|
||||
|
||||
if BUILD_MD5
|
||||
src_libwolfssl_la_SOURCES += wolfcrypt/src/md5.c
|
||||
endif
|
||||
|
||||
if BUILD_PWDBASED
|
||||
src_libwolfssl_la_SOURCES += wolfcrypt/src/pwdbased.c
|
||||
src_libwolfssl_la_SOURCES += wolfcrypt/src/pkcs12.c
|
||||
endif
|
||||
|
||||
if BUILD_DSA
|
||||
src_libwolfssl_la_SOURCES += wolfcrypt/src/dsa.c
|
||||
endif
|
||||
|
||||
if !BUILD_FIPS_V2
|
||||
if BUILD_AESNI
|
||||
src_libwolfssl_la_SOURCES += wolfcrypt/src/aes_asm.S
|
||||
src_libwolfssl_la_SOURCES += wolfcrypt/src/aes_gcm_asm.S
|
||||
endif
|
||||
endif
|
||||
|
||||
if BUILD_CAMELLIA
|
||||
src_libwolfssl_la_SOURCES += wolfcrypt/src/camellia.c
|
||||
endif
|
||||
|
||||
if BUILD_MD2
|
||||
src_libwolfssl_la_SOURCES += wolfcrypt/src/md2.c
|
||||
endif
|
||||
|
||||
if BUILD_RIPEMD
|
||||
src_libwolfssl_la_SOURCES += wolfcrypt/src/ripemd.c
|
||||
endif
|
||||
|
||||
if BUILD_BLAKE2
|
||||
src_libwolfssl_la_SOURCES += wolfcrypt/src/blake2b.c
|
||||
endif
|
||||
if BUILD_BLAKE2S
|
||||
src_libwolfssl_la_SOURCES += wolfcrypt/src/blake2s.c
|
||||
endif
|
||||
|
||||
if BUILD_HC128
|
||||
src_libwolfssl_la_SOURCES += wolfcrypt/src/hc128.c
|
||||
endif
|
||||
|
||||
if BUILD_RABBIT
|
||||
src_libwolfssl_la_SOURCES += wolfcrypt/src/rabbit.c
|
||||
endif
|
||||
|
||||
if BUILD_CHACHA
|
||||
if BUILD_ARMASM
|
||||
src_libwolfssl_la_SOURCES += wolfcrypt/src/port/arm/armv8-chacha.c
|
||||
else
|
||||
src_libwolfssl_la_SOURCES += wolfcrypt/src/chacha.c
|
||||
if BUILD_INTELASM
|
||||
src_libwolfssl_la_SOURCES += wolfcrypt/src/chacha_asm.S
|
||||
endif
|
||||
endif
|
||||
if BUILD_POLY1305
|
||||
src_libwolfssl_la_SOURCES += wolfcrypt/src/chacha20_poly1305.c
|
||||
endif
|
||||
endif
|
||||
|
||||
if !BUILD_INLINE
|
||||
src_libwolfssl_la_SOURCES += wolfcrypt/src/misc.c
|
||||
endif
|
||||
|
||||
if BUILD_FASTMATH
|
||||
src_libwolfssl_la_SOURCES += wolfcrypt/src/tfm.c
|
||||
endif
|
||||
|
||||
if BUILD_SLOWMATH
|
||||
src_libwolfssl_la_SOURCES += wolfcrypt/src/integer.c
|
||||
endif
|
||||
|
||||
if !BUILD_FIPS_V2
|
||||
if BUILD_ECC
|
||||
src_libwolfssl_la_SOURCES += wolfcrypt/src/ecc.c
|
||||
endif
|
||||
endif
|
||||
|
||||
if BUILD_CURVE25519
|
||||
src_libwolfssl_la_SOURCES += wolfcrypt/src/curve25519.c
|
||||
endif
|
||||
|
||||
if BUILD_ED25519
|
||||
src_libwolfssl_la_SOURCES += wolfcrypt/src/ed25519.c
|
||||
endif
|
||||
|
||||
if BUILD_FEMATH
|
||||
if BUILD_CURVE25519_SMALL
|
||||
src_libwolfssl_la_SOURCES += wolfcrypt/src/fe_low_mem.c
|
||||
else
|
||||
if BUILD_INTELASM
|
||||
src_libwolfssl_la_SOURCES += wolfcrypt/src/fe_x25519_asm.S
|
||||
else
|
||||
if BUILD_ARMASM
|
||||
src_libwolfssl_la_SOURCES += wolfcrypt/src/port/arm/armv8-32-curve25519.S
|
||||
src_libwolfssl_la_SOURCES += wolfcrypt/src/port/arm/armv8-curve25519.S
|
||||
else
|
||||
src_libwolfssl_la_SOURCES += wolfcrypt/src/fe_operations.c
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
|
||||
if BUILD_GEMATH
|
||||
if BUILD_ED25519_SMALL
|
||||
src_libwolfssl_la_SOURCES += wolfcrypt/src/ge_low_mem.c
|
||||
else
|
||||
src_libwolfssl_la_SOURCES += wolfcrypt/src/ge_operations.c
|
||||
if !BUILD_FEMATH
|
||||
if BUILD_INTELASM
|
||||
src_libwolfssl_la_SOURCES += wolfcrypt/src/fe_x25519_asm.S
|
||||
else
|
||||
if BUILD_ARMASM
|
||||
src_libwolfssl_la_SOURCES += wolfcrypt/src/port/arm/armv8-curve25519.S
|
||||
else
|
||||
src_libwolfssl_la_SOURCES += wolfcrypt/src/fe_operations.c
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
|
||||
if BUILD_CURVE448
|
||||
src_libwolfssl_la_SOURCES += wolfcrypt/src/curve448.c
|
||||
endif
|
||||
|
||||
if BUILD_ED448
|
||||
src_libwolfssl_la_SOURCES += wolfcrypt/src/ed448.c
|
||||
endif
|
||||
|
||||
if BUILD_FE448
|
||||
src_libwolfssl_la_SOURCES += wolfcrypt/src/fe_448.c
|
||||
endif
|
||||
|
||||
if BUILD_GE448
|
||||
src_libwolfssl_la_SOURCES += wolfcrypt/src/ge_448.c
|
||||
if !BUILD_FE448
|
||||
src_libwolfssl_la_SOURCES += wolfcrypt/src/fe_448.c
|
||||
endif
|
||||
endif
|
||||
|
||||
if BUILD_LIBZ
|
||||
src_libwolfssl_la_SOURCES += wolfcrypt/src/compress.c
|
||||
endif
|
||||
|
||||
if BUILD_PKCS7
|
||||
src_libwolfssl_la_SOURCES += wolfcrypt/src/pkcs7.c
|
||||
endif
|
||||
|
||||
if BUILD_SRP
|
||||
src_libwolfssl_la_SOURCES += wolfcrypt/src/srp.c
|
||||
endif
|
||||
|
||||
if BUILD_IDEA
|
||||
src_libwolfssl_la_SOURCES += wolfcrypt/src/idea.c
|
||||
endif
|
||||
|
||||
if BUILD_AFALG
|
||||
src_libwolfssl_la_SOURCES += wolfcrypt/src/port/af_alg/wc_afalg.c
|
||||
endif
|
||||
|
||||
if !BUILD_CRYPTONLY
|
||||
# ssl files
|
||||
src_libwolfssl_la_SOURCES += \
|
||||
src/internal.c \
|
||||
src/wolfio.c \
|
||||
src/keys.c \
|
||||
src/ssl.c \
|
||||
src/tls.c
|
||||
|
||||
if BUILD_TLS13
|
||||
src_libwolfssl_la_SOURCES += src/tls13.c
|
||||
endif
|
||||
|
||||
if BUILD_OCSP
|
||||
src_libwolfssl_la_SOURCES += src/ocsp.c
|
||||
endif
|
||||
|
||||
if BUILD_CRL
|
||||
src_libwolfssl_la_SOURCES += src/crl.c
|
||||
endif
|
||||
|
||||
if BUILD_SNIFFER
|
||||
src_libwolfssl_la_SOURCES += src/sniffer.c
|
||||
endif
|
||||
|
||||
endif !BUILD_CRYPTONLY
|
||||
|
||||
endif !BUILD_FIPS_RAND
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -1,41 +0,0 @@
|
||||
# libwolfssl.la - a libtool library file
|
||||
# Generated by libtool (GNU libtool) 2.4.6 Debian-2.4.6-2
|
||||
#
|
||||
# Please DO NOT delete this file!
|
||||
# It is necessary for linking the library.
|
||||
|
||||
# The name that we can dlopen(3).
|
||||
dlname='libwolfssl.so.24'
|
||||
|
||||
# Names of this library.
|
||||
library_names='libwolfssl.so.24.1.0 libwolfssl.so.24 libwolfssl.so'
|
||||
|
||||
# The name of the static archive.
|
||||
old_library=''
|
||||
|
||||
# Linker flags that cannot go in dependency_libs.
|
||||
inherited_linker_flags=' -pthread'
|
||||
|
||||
# Libraries that this one depends upon.
|
||||
dependency_libs=' -lm'
|
||||
|
||||
# Names of additional weak libraries provided by this library
|
||||
weak_library_names=''
|
||||
|
||||
# Version information for libwolfssl.
|
||||
current=25
|
||||
age=1
|
||||
revision=0
|
||||
|
||||
# Is this an already installed library?
|
||||
installed=no
|
||||
|
||||
# Should we warn about portability when linking against -modules?
|
||||
shouldnotlink=no
|
||||
|
||||
# Files to dlopen/dlpreopen
|
||||
dlopen=''
|
||||
dlpreopen=''
|
||||
|
||||
# Directory that this library needs to be installed in:
|
||||
libdir='/usr/local/lib'
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -1,12 +0,0 @@
|
||||
# src/src_libwolfssl_la-internal.lo - a libtool object file
|
||||
# Generated by libtool (GNU libtool) 2.4.6 Debian-2.4.6-2
|
||||
#
|
||||
# Please DO NOT delete this file!
|
||||
# It is necessary for linking the library.
|
||||
|
||||
# Name of the PIC object.
|
||||
pic_object='.libs/src_libwolfssl_la-internal.o'
|
||||
|
||||
# Name of the non-PIC object
|
||||
non_pic_object=none
|
||||
|
@ -1,12 +0,0 @@
|
||||
# src/src_libwolfssl_la-keys.lo - a libtool object file
|
||||
# Generated by libtool (GNU libtool) 2.4.6 Debian-2.4.6-2
|
||||
#
|
||||
# Please DO NOT delete this file!
|
||||
# It is necessary for linking the library.
|
||||
|
||||
# Name of the PIC object.
|
||||
pic_object='.libs/src_libwolfssl_la-keys.o'
|
||||
|
||||
# Name of the non-PIC object
|
||||
non_pic_object=none
|
||||
|
@ -1,12 +0,0 @@
|
||||
# src/src_libwolfssl_la-ssl.lo - a libtool object file
|
||||
# Generated by libtool (GNU libtool) 2.4.6 Debian-2.4.6-2
|
||||
#
|
||||
# Please DO NOT delete this file!
|
||||
# It is necessary for linking the library.
|
||||
|
||||
# Name of the PIC object.
|
||||
pic_object='.libs/src_libwolfssl_la-ssl.o'
|
||||
|
||||
# Name of the non-PIC object
|
||||
non_pic_object=none
|
||||
|
@ -1,12 +0,0 @@
|
||||
# src/src_libwolfssl_la-tls.lo - a libtool object file
|
||||
# Generated by libtool (GNU libtool) 2.4.6 Debian-2.4.6-2
|
||||
#
|
||||
# Please DO NOT delete this file!
|
||||
# It is necessary for linking the library.
|
||||
|
||||
# Name of the PIC object.
|
||||
pic_object='.libs/src_libwolfssl_la-tls.o'
|
||||
|
||||
# Name of the non-PIC object
|
||||
non_pic_object=none
|
||||
|
@ -1,12 +0,0 @@
|
||||
# src/src_libwolfssl_la-wolfio.lo - a libtool object file
|
||||
# Generated by libtool (GNU libtool) 2.4.6 Debian-2.4.6-2
|
||||
#
|
||||
# Please DO NOT delete this file!
|
||||
# It is necessary for linking the library.
|
||||
|
||||
# Name of the PIC object.
|
||||
pic_object='.libs/src_libwolfssl_la-wolfio.o'
|
||||
|
||||
# Name of the non-PIC object
|
||||
non_pic_object=none
|
||||
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -1,24 +0,0 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
#
|
||||
# Our valgrind "error" wrapper.
|
||||
|
||||
TMP="valgrind.tmp.$$"
|
||||
|
||||
valgrind --suppressions=valgrind-bash.supp --leak-check=full -q "$@" 2> $TMP
|
||||
|
||||
result="$?"
|
||||
|
||||
# verify no errors
|
||||
|
||||
output="`cat $TMP`"
|
||||
|
||||
if [ "$output" != "" ]; then
|
||||
cat $TMP >&2
|
||||
result=1
|
||||
fi
|
||||
|
||||
rm $TMP
|
||||
|
||||
exit $result
|
||||
|
@ -1,103 +0,0 @@
|
||||
# wolfCrypt Benchmarks
|
||||
|
||||
Tool for performing cryptographic algorithm benchmarking.
|
||||
|
||||
## Measurements
|
||||
|
||||
* Symmetric algorithms like AES and ChaCha20 are measured in Killobytes (KB) or Megabytes (MB) per second.
|
||||
* Asymmetric algorithms like RSA and ECC are measured using Operations Per Second (Ops) per second.
|
||||
|
||||
## Usage
|
||||
|
||||
```sh
|
||||
./wolfcrypt/benchmark/benchmark -?
|
||||
benchmark
|
||||
-? <num> Help, print this usage
|
||||
0: English, 1: Japanese
|
||||
-csv Print terminal output in csv format
|
||||
-base10 Display bytes as power of 10 (eg 1 kB = 1000 Bytes)
|
||||
-no_aad No additional authentication data passed.
|
||||
-dgst_full Full digest operation performed.
|
||||
-rsa_sign Measure RSA sign/verify instead of encrypt/decrypt.
|
||||
<keySz> -rsa-sz
|
||||
Measure RSA <key size> performance.
|
||||
-<alg> Algorithm to benchmark. Available algorithms include:
|
||||
cipher aes-cbc aes-gcm aes-ecb aes-xts aes-cfb aes-ctr aes-ccm
|
||||
camellia arc4 hc128 rabbit chacha20 chacha20-poly1305 des idea
|
||||
digest md5 poly1305 sha sha2 sha224 sha256 sha384 sha512 sha3
|
||||
sha3-224 sha3-256 sha3-384 sha3-512 ripemd
|
||||
mac cmac hmac hmac-md5 hmac-sha hmac-sha224 hmac-sha256
|
||||
hmac-sha384 hmac-sha512 pbkdf2
|
||||
asym rsa-kg rsa rsa-sz dh ecc-kg ecc ecc-enc curve25519_kg x25519
|
||||
ed25519-kg ed25519
|
||||
other rng scrypt
|
||||
-lng <num> Display benchmark result by specified language.
|
||||
0: English, 1: Japanese
|
||||
<num> Size of block in bytes
|
||||
```
|
||||
|
||||
The `-base10` option shows as thousands of bytes (kB).
|
||||
|
||||
## Example Output
|
||||
|
||||
Run on Intel(R) Core(TM) i7-7920HQ CPU @ 3.10GHz.
|
||||
|
||||
```sh
|
||||
./configure --enable-intelasm --enable-aesni --enable-sp --enable-sp-asm && make
|
||||
|
||||
./wolfcrypt/benchmark/benchmark
|
||||
------------------------------------------------------------------------------
|
||||
wolfSSL version 4.0.0
|
||||
------------------------------------------------------------------------------
|
||||
wolfCrypt Benchmark (block bytes 1048576, min 1.0 sec each)
|
||||
RNG 180 MB took 1.022 seconds, 176.201 MB/s Cycles per byte = 16.76
|
||||
AES-128-CBC-enc 1250 MB took 1.002 seconds, 1247.878 MB/s Cycles per byte = 2.37
|
||||
AES-128-CBC-dec 4595 MB took 1.001 seconds, 4591.703 MB/s Cycles per byte = 0.64
|
||||
AES-192-CBC-enc 1005 MB took 1.003 seconds, 1002.018 MB/s Cycles per byte = 2.95
|
||||
AES-192-CBC-dec 4345 MB took 1.000 seconds, 4344.744 MB/s Cycles per byte = 0.68
|
||||
AES-256-CBC-enc 905 MB took 1.005 seconds, 900.386 MB/s Cycles per byte = 3.28
|
||||
AES-256-CBC-dec 3255 MB took 1.001 seconds, 3251.618 MB/s Cycles per byte = 0.91
|
||||
AES-128-GCM-enc 4730 MB took 1.001 seconds, 4726.267 MB/s Cycles per byte = 0.62
|
||||
AES-128-GCM-dec 5140 MB took 1.000 seconds, 5137.596 MB/s Cycles per byte = 0.57
|
||||
AES-192-GCM-enc 4475 MB took 1.001 seconds, 4471.056 MB/s Cycles per byte = 0.66
|
||||
AES-192-GCM-dec 3405 MB took 1.001 seconds, 3403.179 MB/s Cycles per byte = 0.87
|
||||
AES-256-GCM-enc 2640 MB took 1.000 seconds, 2638.905 MB/s Cycles per byte = 1.12
|
||||
AES-256-GCM-dec 2780 MB took 1.001 seconds, 2776.632 MB/s Cycles per byte = 1.06
|
||||
CHACHA 2615 MB took 1.000 seconds, 2614.357 MB/s Cycles per byte = 1.13
|
||||
CHA-POLY 1490 MB took 1.001 seconds, 1488.344 MB/s Cycles per byte = 1.98
|
||||
MD5 440 MB took 1.010 seconds, 435.763 MB/s Cycles per byte = 6.78
|
||||
POLY1305 4900 MB took 1.001 seconds, 4896.430 MB/s Cycles per byte = 0.60
|
||||
SHA 515 MB took 1.011 seconds, 509.459 MB/s Cycles per byte = 5.80
|
||||
SHA-224 425 MB took 1.005 seconds, 422.737 MB/s Cycles per byte = 6.98
|
||||
SHA-256 420 MB took 1.006 seconds, 417.312 MB/s Cycles per byte = 7.08
|
||||
SHA-384 615 MB took 1.003 seconds, 613.018 MB/s Cycles per byte = 4.82
|
||||
SHA-512 560 MB took 1.007 seconds, 556.230 MB/s Cycles per byte = 5.31
|
||||
SHA3-224 295 MB took 1.003 seconds, 294.133 MB/s Cycles per byte = 10.04
|
||||
SHA3-256 280 MB took 1.003 seconds, 279.088 MB/s Cycles per byte = 10.58
|
||||
SHA3-384 215 MB took 1.002 seconds, 214.654 MB/s Cycles per byte = 13.76
|
||||
SHA3-512 145 MB took 1.005 seconds, 144.266 MB/s Cycles per byte = 20.47
|
||||
HMAC-MD5 485 MB took 1.004 seconds, 483.019 MB/s Cycles per byte = 6.11
|
||||
HMAC-SHA 505 MB took 1.006 seconds, 502.159 MB/s Cycles per byte = 5.88
|
||||
HMAC-SHA224 415 MB took 1.007 seconds, 411.965 MB/s Cycles per byte = 7.17
|
||||
HMAC-SHA256 380 MB took 1.002 seconds, 379.398 MB/s Cycles per byte = 7.78
|
||||
HMAC-SHA384 610 MB took 1.006 seconds, 606.370 MB/s Cycles per byte = 4.87
|
||||
HMAC-SHA512 620 MB took 1.001 seconds, 619.377 MB/s Cycles per byte = 4.77
|
||||
RSA 2048 public 52000 ops took 1.001 sec, avg 0.019 ms, 51932.223 ops/sec
|
||||
RSA 2048 private 1700 ops took 1.022 sec, avg 0.601 ms, 1662.697 ops/sec
|
||||
DH 2048 key gen 3491 ops took 1.000 sec, avg 0.286 ms, 3490.745 ops/sec
|
||||
DH 2048 agree 3500 ops took 1.014 sec, avg 0.290 ms, 3452.191 ops/sec
|
||||
ECC 256 key gen 88961 ops took 1.000 sec, avg 0.011 ms, 88960.279 ops/sec
|
||||
ECDHE 256 agree 20700 ops took 1.005 sec, avg 0.049 ms, 20605.239 ops/sec
|
||||
ECDSA 256 sign 53200 ops took 1.001 sec, avg 0.019 ms, 53157.214 ops/sec
|
||||
ECDSA 256 verify 17200 ops took 1.004 sec, avg 0.058 ms, 17124.208 ops/sec
|
||||
Benchmark complete
|
||||
```
|
||||
|
||||
|
||||
## Windows Visual Studio
|
||||
|
||||
For building wolfCrypt Benchmark project in Visual Studio open the `benchmark.sln`. For newer Visual Studio version it may prompt for a one-way upgrade. Then you may have to right-click on the solution and choose `Retarget solution` to update the project files for your Visual Studio version.
|
||||
|
||||
If you see an error about `rc.exe` then you'll need to update the "Target Platform Version". You can do this by right-clicking on the benchmark project -> General -> "Target Platform Version" and changing to 8.1 (needs to match the wolfssl library project).
|
||||
|
||||
This solution includes the wolfSSL library project at `<wolfssl-root>wolfssl.vcxproj` and will compile the library, then the benchmark project.
|
File diff suppressed because it is too large
Load Diff
@ -1,111 +0,0 @@
|
||||
/* wolfcrypt/benchmark/benchmark.h
|
||||
*
|
||||
* Copyright (C) 2006-2020 wolfSSL Inc.
|
||||
*
|
||||
* This file is part of wolfSSL.
|
||||
*
|
||||
* wolfSSL is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* wolfSSL is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA
|
||||
*/
|
||||
|
||||
|
||||
#ifndef WOLFCRYPT_BENCHMARK_H
|
||||
#define WOLFCRYPT_BENCHMARK_H
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* run all benchmark entry */
|
||||
#ifdef HAVE_STACK_SIZE
|
||||
THREAD_RETURN WOLFSSL_THREAD benchmark_test(void* args);
|
||||
#else
|
||||
int benchmark_test(void *args);
|
||||
#endif
|
||||
|
||||
/* individual benchmarks */
|
||||
int benchmark_init(void);
|
||||
int benchmark_free(void);
|
||||
void benchmark_configure(int block_size);
|
||||
|
||||
void bench_des(int);
|
||||
void bench_idea(void);
|
||||
void bench_arc4(int);
|
||||
void bench_hc128(void);
|
||||
void bench_rabbit(void);
|
||||
void bench_chacha(void);
|
||||
void bench_chacha20_poly1305_aead(void);
|
||||
void bench_aescbc(int);
|
||||
void bench_aesgcm(int);
|
||||
void bench_aesccm(void);
|
||||
void bench_aesecb(int);
|
||||
void bench_aesxts(void);
|
||||
void bench_aesctr(void);
|
||||
void bench_aescfb(void);
|
||||
void bench_aesofb(void);
|
||||
void bench_poly1305(void);
|
||||
void bench_camellia(void);
|
||||
void bench_md5(int);
|
||||
void bench_sha(int);
|
||||
void bench_sha224(int);
|
||||
void bench_sha256(int);
|
||||
void bench_sha384(int);
|
||||
void bench_sha512(int);
|
||||
void bench_sha3_224(int);
|
||||
void bench_sha3_256(int);
|
||||
void bench_sha3_384(int);
|
||||
void bench_sha3_512(int);
|
||||
int bench_ripemd(void);
|
||||
void bench_cmac(void);
|
||||
void bench_scrypt(void);
|
||||
void bench_hmac_md5(int);
|
||||
void bench_hmac_sha(int);
|
||||
void bench_hmac_sha224(int);
|
||||
void bench_hmac_sha256(int);
|
||||
void bench_hmac_sha384(int);
|
||||
void bench_hmac_sha512(int);
|
||||
void bench_rsaKeyGen(int);
|
||||
void bench_rsaKeyGen_size(int, int);
|
||||
void bench_rsa(int);
|
||||
void bench_rsa_key(int, int);
|
||||
void bench_dh(int);
|
||||
void bench_eccMakeKey(int);
|
||||
void bench_ecc(int);
|
||||
void bench_eccEncrypt(void);
|
||||
void bench_curve25519KeyGen(void);
|
||||
void bench_curve25519KeyAgree(void);
|
||||
void bench_ed25519KeyGen(void);
|
||||
void bench_ed25519KeySign(void);
|
||||
void bench_curve448KeyGen(void);
|
||||
void bench_curve448KeyAgree(void);
|
||||
void bench_ed448KeyGen(void);
|
||||
void bench_ed448KeySign(void);
|
||||
void bench_ntru(void);
|
||||
void bench_ntruKeyGen(void);
|
||||
void bench_rng(void);
|
||||
void bench_blake2b(void);
|
||||
void bench_blake2s(void);
|
||||
void bench_pbkdf2(void);
|
||||
|
||||
void bench_stats_print(void);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
|
||||
|
||||
#endif /* WOLFCRYPT_BENCHMARK_H */
|
||||
|
@ -1,197 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<VisualStudioProject
|
||||
ProjectType="Visual C++"
|
||||
Version="8.00"
|
||||
Name="benchmark"
|
||||
ProjectGUID="{615AEC46-5595-4DEA-9490-DBD5DE0F8772}"
|
||||
Keyword="Win32Proj"
|
||||
>
|
||||
<Platforms>
|
||||
<Platform
|
||||
Name="Win32"
|
||||
/>
|
||||
</Platforms>
|
||||
<ToolFiles>
|
||||
</ToolFiles>
|
||||
<Configurations>
|
||||
<Configuration
|
||||
Name="Debug|Win32"
|
||||
OutputDirectory="Debug"
|
||||
IntermediateDirectory="Debug"
|
||||
ConfigurationType="1"
|
||||
>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
AdditionalIncludeDirectories="../..;../../IDE/WIN;"
|
||||
PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE;WOLFSSL_LIB;WOLFSSL_USER_SETTINGS;"
|
||||
MinimalRebuild="true"
|
||||
BasicRuntimeChecks="3"
|
||||
RuntimeLibrary="3"
|
||||
UsePrecompiledHeader="0"
|
||||
WarningLevel="3"
|
||||
Detect64BitPortabilityProblems="true"
|
||||
DebugInformationFormat="4"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManagedResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
AdditionalDependencies="Ws2_32.lib"
|
||||
LinkIncremental="2"
|
||||
GenerateDebugInformation="true"
|
||||
SubSystem="1"
|
||||
TargetMachine="1"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCALinkTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManifestTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXDCMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCBscMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCFxCopTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCAppVerifierTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCWebDeploymentTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"
|
||||
/>
|
||||
</Configuration>
|
||||
<Configuration
|
||||
Name="Release|Win32"
|
||||
OutputDirectory="Release"
|
||||
IntermediateDirectory="Release"
|
||||
ConfigurationType="1"
|
||||
>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
AdditionalIncludeDirectories="../..;../../IDE/WIN;"
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;WOLFSSL_LIB;WOLFSSL_USER_SETTINGS;"
|
||||
RuntimeLibrary="2"
|
||||
UsePrecompiledHeader="0"
|
||||
WarningLevel="3"
|
||||
Detect64BitPortabilityProblems="true"
|
||||
DebugInformationFormat="3"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManagedResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
AdditionalDependencies="Ws2_32.lib"
|
||||
LinkIncremental="2"
|
||||
GenerateDebugInformation="true"
|
||||
SubSystem="1"
|
||||
OptimizeReferences="2"
|
||||
EnableCOMDATFolding="2"
|
||||
TargetMachine="1"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCALinkTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManifestTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXDCMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCBscMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCFxCopTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCAppVerifierTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCWebDeploymentTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"
|
||||
/>
|
||||
</Configuration>
|
||||
</Configurations>
|
||||
<References>
|
||||
</References>
|
||||
<Files>
|
||||
<Filter
|
||||
Name="Header Files"
|
||||
Filter="h;hpp;hxx;hm;inl;inc;xsd"
|
||||
UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
|
||||
>
|
||||
</Filter>
|
||||
<Filter
|
||||
Name="Resource Files"
|
||||
Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx"
|
||||
UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}"
|
||||
>
|
||||
</Filter>
|
||||
<Filter
|
||||
Name="Source Files"
|
||||
Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
|
||||
UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
|
||||
>
|
||||
<File
|
||||
RelativePath=".\benchmark.c"
|
||||
>
|
||||
</File>
|
||||
</Filter>
|
||||
</Files>
|
||||
<Globals>
|
||||
</Globals>
|
||||
</VisualStudioProject>
|
@ -1,14 +0,0 @@
|
||||
# vim:ft=automake
|
||||
# All paths should be given relative to the root
|
||||
|
||||
if BUILD_WOLFCRYPT_TESTS
|
||||
noinst_PROGRAMS += wolfcrypt/benchmark/benchmark
|
||||
wolfcrypt_benchmark_benchmark_SOURCES = wolfcrypt/benchmark/benchmark.c
|
||||
wolfcrypt_benchmark_benchmark_LDADD = src/libwolfssl.la $(LIB_STATIC_ADD)
|
||||
wolfcrypt_benchmark_benchmark_DEPENDENCIES = src/libwolfssl.la
|
||||
noinst_HEADERS += wolfcrypt/benchmark/benchmark.h
|
||||
endif
|
||||
EXTRA_DIST += wolfcrypt/benchmark/benchmark.sln
|
||||
EXTRA_DIST += wolfcrypt/benchmark/benchmark.vcproj
|
||||
EXTRA_DIST += wolfcrypt/benchmark/README.md
|
||||
DISTCLEANFILES+= wolfcrypt/benchmark/.libs/benchmark
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -1,149 +0,0 @@
|
||||
/* arc4.c
|
||||
*
|
||||
* Copyright (C) 2006-2020 wolfSSL Inc.
|
||||
*
|
||||
* This file is part of wolfSSL.
|
||||
*
|
||||
* wolfSSL is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* wolfSSL is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA
|
||||
*/
|
||||
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
#endif
|
||||
|
||||
#include <wolfssl/wolfcrypt/settings.h>
|
||||
|
||||
#ifndef NO_RC4
|
||||
|
||||
#include <wolfssl/wolfcrypt/error-crypt.h>
|
||||
#include <wolfssl/wolfcrypt/arc4.h>
|
||||
|
||||
|
||||
int wc_Arc4SetKey(Arc4* arc4, const byte* key, word32 length)
|
||||
{
|
||||
int ret = 0;
|
||||
word32 i;
|
||||
word32 keyIndex = 0, stateIndex = 0;
|
||||
|
||||
if (arc4 == NULL || key == NULL || length == 0) {
|
||||
return BAD_FUNC_ARG;
|
||||
}
|
||||
|
||||
#if defined(WOLFSSL_ASYNC_CRYPT) && defined(WC_ASYNC_ENABLE_ARC4) && \
|
||||
defined(HAVE_CAVIUM) && !defined(HAVE_CAVIUM_V)
|
||||
if (arc4->asyncDev.marker == WOLFSSL_ASYNC_MARKER_ARC4) {
|
||||
return NitroxArc4SetKey(arc4, key, length);
|
||||
}
|
||||
#endif
|
||||
|
||||
arc4->x = 1;
|
||||
arc4->y = 0;
|
||||
|
||||
for (i = 0; i < ARC4_STATE_SIZE; i++)
|
||||
arc4->state[i] = (byte)i;
|
||||
|
||||
for (i = 0; i < ARC4_STATE_SIZE; i++) {
|
||||
word32 a = arc4->state[i];
|
||||
stateIndex += key[keyIndex] + a;
|
||||
stateIndex &= 0xFF;
|
||||
arc4->state[i] = arc4->state[stateIndex];
|
||||
arc4->state[stateIndex] = (byte)a;
|
||||
|
||||
if (++keyIndex >= length)
|
||||
keyIndex = 0;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
static WC_INLINE byte MakeByte(word32* x, word32* y, byte* s)
|
||||
{
|
||||
word32 a = s[*x], b;
|
||||
*y = (*y+a) & 0xff;
|
||||
|
||||
b = s[*y];
|
||||
s[*x] = (byte)b;
|
||||
s[*y] = (byte)a;
|
||||
*x = (*x+1) & 0xff;
|
||||
|
||||
return s[(a+b) & 0xff];
|
||||
}
|
||||
|
||||
|
||||
int wc_Arc4Process(Arc4* arc4, byte* out, const byte* in, word32 length)
|
||||
{
|
||||
int ret = 0;
|
||||
word32 x;
|
||||
word32 y;
|
||||
|
||||
if (arc4 == NULL || out == NULL || in == NULL) {
|
||||
return BAD_FUNC_ARG;
|
||||
}
|
||||
|
||||
#if defined(WOLFSSL_ASYNC_CRYPT) && defined(WC_ASYNC_ENABLE_ARC4) && \
|
||||
defined(HAVE_CAVIUM) && !defined(HAVE_CAVIUM_V)
|
||||
if (arc4->asyncDev.marker == WOLFSSL_ASYNC_MARKER_ARC4) {
|
||||
return NitroxArc4Process(arc4, out, in, length);
|
||||
}
|
||||
#endif
|
||||
|
||||
x = arc4->x;
|
||||
y = arc4->y;
|
||||
|
||||
while(length--)
|
||||
*out++ = *in++ ^ MakeByte(&x, &y, arc4->state);
|
||||
|
||||
arc4->x = (byte)x;
|
||||
arc4->y = (byte)y;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* Initialize Arc4 for use with async device */
|
||||
int wc_Arc4Init(Arc4* arc4, void* heap, int devId)
|
||||
{
|
||||
int ret = 0;
|
||||
|
||||
if (arc4 == NULL)
|
||||
return BAD_FUNC_ARG;
|
||||
|
||||
arc4->heap = heap;
|
||||
|
||||
#if defined(WOLFSSL_ASYNC_CRYPT) && defined(WC_ASYNC_ENABLE_ARC4)
|
||||
ret = wolfAsync_DevCtxInit(&arc4->asyncDev, WOLFSSL_ASYNC_MARKER_ARC4,
|
||||
arc4->heap, devId);
|
||||
#else
|
||||
(void)devId;
|
||||
#endif /* WOLFSSL_ASYNC_CRYPT */
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
/* Free Arc4 from use with async device */
|
||||
void wc_Arc4Free(Arc4* arc4)
|
||||
{
|
||||
if (arc4 == NULL)
|
||||
return;
|
||||
|
||||
#if defined(WOLFSSL_ASYNC_CRYPT) && defined(WC_ASYNC_ENABLE_ARC4)
|
||||
wolfAsync_DevCtxFree(&arc4->asyncDev, WOLFSSL_ASYNC_MARKER_ARC4);
|
||||
#endif /* WOLFSSL_ASYNC_CRYPT */
|
||||
}
|
||||
|
||||
#endif /* NO_RC4 */
|
||||
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -1,452 +0,0 @@
|
||||
/*
|
||||
BLAKE2 reference source code package - reference C implementations
|
||||
|
||||
Written in 2012 by Samuel Neves <sneves@dei.uc.pt>
|
||||
|
||||
To the extent possible under law, the author(s) have dedicated all copyright
|
||||
and related and neighboring rights to this software to the public domain
|
||||
worldwide. This software is distributed without any warranty.
|
||||
|
||||
You should have received a copy of the CC0 Public Domain Dedication along with
|
||||
this software. If not, see <http://creativecommons.org/publicdomain/zero/1.0/>.
|
||||
*/
|
||||
/* blake2b.c
|
||||
*
|
||||
* Copyright (C) 2006-2020 wolfSSL Inc.
|
||||
*
|
||||
* This file is part of wolfSSL.
|
||||
*
|
||||
* wolfSSL is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* wolfSSL is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA
|
||||
*/
|
||||
|
||||
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
#endif
|
||||
|
||||
#include <wolfssl/wolfcrypt/settings.h>
|
||||
|
||||
#ifdef HAVE_BLAKE2
|
||||
|
||||
#include <wolfssl/wolfcrypt/blake2.h>
|
||||
#include <wolfssl/wolfcrypt/blake2-impl.h>
|
||||
|
||||
|
||||
static const word64 blake2b_IV[8] =
|
||||
{
|
||||
0x6a09e667f3bcc908ULL, 0xbb67ae8584caa73bULL,
|
||||
0x3c6ef372fe94f82bULL, 0xa54ff53a5f1d36f1ULL,
|
||||
0x510e527fade682d1ULL, 0x9b05688c2b3e6c1fULL,
|
||||
0x1f83d9abfb41bd6bULL, 0x5be0cd19137e2179ULL
|
||||
};
|
||||
|
||||
static const byte blake2b_sigma[12][16] =
|
||||
{
|
||||
{ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 } ,
|
||||
{ 14, 10, 4, 8, 9, 15, 13, 6, 1, 12, 0, 2, 11, 7, 5, 3 } ,
|
||||
{ 11, 8, 12, 0, 5, 2, 15, 13, 10, 14, 3, 6, 7, 1, 9, 4 } ,
|
||||
{ 7, 9, 3, 1, 13, 12, 11, 14, 2, 6, 5, 10, 4, 0, 15, 8 } ,
|
||||
{ 9, 0, 5, 7, 2, 4, 10, 15, 14, 1, 11, 12, 6, 8, 3, 13 } ,
|
||||
{ 2, 12, 6, 10, 0, 11, 8, 3, 4, 13, 7, 5, 15, 14, 1, 9 } ,
|
||||
{ 12, 5, 1, 15, 14, 13, 4, 10, 0, 7, 6, 3, 9, 2, 8, 11 } ,
|
||||
{ 13, 11, 7, 14, 12, 1, 3, 9, 5, 0, 15, 4, 8, 6, 2, 10 } ,
|
||||
{ 6, 15, 14, 9, 11, 3, 0, 8, 12, 2, 13, 7, 1, 4, 10, 5 } ,
|
||||
{ 10, 2, 8, 4, 7, 6, 1, 5, 15, 11, 9, 14, 3, 12, 13 , 0 } ,
|
||||
{ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 } ,
|
||||
{ 14, 10, 4, 8, 9, 15, 13, 6, 1, 12, 0, 2, 11, 7, 5, 3 }
|
||||
};
|
||||
|
||||
|
||||
static WC_INLINE int blake2b_set_lastnode( blake2b_state *S )
|
||||
{
|
||||
S->f[1] = ~0ULL;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Some helper functions, not necessarily useful */
|
||||
static WC_INLINE int blake2b_set_lastblock( blake2b_state *S )
|
||||
{
|
||||
if( S->last_node ) blake2b_set_lastnode( S );
|
||||
|
||||
S->f[0] = ~0ULL;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static WC_INLINE int blake2b_increment_counter( blake2b_state *S, const word64
|
||||
inc )
|
||||
{
|
||||
S->t[0] += inc;
|
||||
S->t[1] += ( S->t[0] < inc );
|
||||
return 0;
|
||||
}
|
||||
|
||||
static WC_INLINE int blake2b_init0( blake2b_state *S )
|
||||
{
|
||||
int i;
|
||||
XMEMSET( S, 0, sizeof( blake2b_state ) );
|
||||
|
||||
for( i = 0; i < 8; ++i ) S->h[i] = blake2b_IV[i];
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* init xors IV with input parameter block */
|
||||
int blake2b_init_param( blake2b_state *S, const blake2b_param *P )
|
||||
{
|
||||
word32 i;
|
||||
byte *p ;
|
||||
blake2b_init0( S );
|
||||
p = ( byte * )( P );
|
||||
|
||||
/* IV XOR ParamBlock */
|
||||
for( i = 0; i < 8; ++i )
|
||||
S->h[i] ^= load64( p + sizeof( S->h[i] ) * i );
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
int blake2b_init( blake2b_state *S, const byte outlen )
|
||||
{
|
||||
blake2b_param P[1];
|
||||
|
||||
if ( ( !outlen ) || ( outlen > BLAKE2B_OUTBYTES ) ) return -1;
|
||||
|
||||
#ifdef WOLFSSL_BLAKE2B_INIT_EACH_FIELD
|
||||
P->digest_length = outlen;
|
||||
P->key_length = 0;
|
||||
P->fanout = 1;
|
||||
P->depth = 1;
|
||||
store32( &P->leaf_length, 0 );
|
||||
store64( &P->node_offset, 0 );
|
||||
P->node_depth = 0;
|
||||
P->inner_length = 0;
|
||||
XMEMSET( P->reserved, 0, sizeof( P->reserved ) );
|
||||
XMEMSET( P->salt, 0, sizeof( P->salt ) );
|
||||
XMEMSET( P->personal, 0, sizeof( P->personal ) );
|
||||
#else
|
||||
XMEMSET( P, 0, sizeof( *P ) );
|
||||
P->digest_length = outlen;
|
||||
P->fanout = 1;
|
||||
P->depth = 1;
|
||||
#endif
|
||||
return blake2b_init_param( S, P );
|
||||
}
|
||||
|
||||
|
||||
int blake2b_init_key( blake2b_state *S, const byte outlen, const void *key,
|
||||
const byte keylen )
|
||||
{
|
||||
blake2b_param P[1];
|
||||
|
||||
if ( ( !outlen ) || ( outlen > BLAKE2B_OUTBYTES ) ) return -1;
|
||||
|
||||
if ( !key || !keylen || keylen > BLAKE2B_KEYBYTES ) return -1;
|
||||
|
||||
#ifdef WOLFSSL_BLAKE2B_INIT_EACH_FIELD
|
||||
P->digest_length = outlen;
|
||||
P->key_length = keylen;
|
||||
P->fanout = 1;
|
||||
P->depth = 1;
|
||||
store32( &P->leaf_length, 0 );
|
||||
store64( &P->node_offset, 0 );
|
||||
P->node_depth = 0;
|
||||
P->inner_length = 0;
|
||||
XMEMSET( P->reserved, 0, sizeof( P->reserved ) );
|
||||
XMEMSET( P->salt, 0, sizeof( P->salt ) );
|
||||
XMEMSET( P->personal, 0, sizeof( P->personal ) );
|
||||
#else
|
||||
XMEMSET( P, 0, sizeof( *P ) );
|
||||
P->digest_length = outlen;
|
||||
P->key_length = keylen;
|
||||
P->fanout = 1;
|
||||
P->depth = 1;
|
||||
#endif
|
||||
|
||||
if( blake2b_init_param( S, P ) < 0 ) return -1;
|
||||
|
||||
{
|
||||
#ifdef WOLFSSL_SMALL_STACK
|
||||
byte* block;
|
||||
|
||||
block = (byte*)XMALLOC(BLAKE2B_BLOCKBYTES, NULL, DYNAMIC_TYPE_TMP_BUFFER);
|
||||
|
||||
if ( block == NULL ) return -1;
|
||||
#else
|
||||
byte block[BLAKE2B_BLOCKBYTES];
|
||||
#endif
|
||||
|
||||
XMEMSET( block, 0, BLAKE2B_BLOCKBYTES );
|
||||
XMEMCPY( block, key, keylen );
|
||||
blake2b_update( S, block, BLAKE2B_BLOCKBYTES );
|
||||
secure_zero_memory( block, BLAKE2B_BLOCKBYTES ); /* Burn the key from */
|
||||
/* memory */
|
||||
|
||||
#ifdef WOLFSSL_SMALL_STACK
|
||||
XFREE(block, NULL, DYNAMIC_TYPE_TMP_BUFFER);
|
||||
#endif
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int blake2b_compress( blake2b_state *S,
|
||||
const byte block[BLAKE2B_BLOCKBYTES] )
|
||||
{
|
||||
int i;
|
||||
|
||||
#ifdef WOLFSSL_SMALL_STACK
|
||||
word64* m;
|
||||
word64* v;
|
||||
|
||||
m = (word64*)XMALLOC(sizeof(word64) * 16, NULL, DYNAMIC_TYPE_TMP_BUFFER);
|
||||
|
||||
if ( m == NULL ) return -1;
|
||||
|
||||
v = (word64*)XMALLOC(sizeof(word64) * 16, NULL, DYNAMIC_TYPE_TMP_BUFFER);
|
||||
|
||||
if ( v == NULL )
|
||||
{
|
||||
XFREE(m, NULL, DYNAMIC_TYPE_TMP_BUFFER);
|
||||
return -1;
|
||||
}
|
||||
#else
|
||||
word64 m[16];
|
||||
word64 v[16];
|
||||
#endif
|
||||
|
||||
for( i = 0; i < 16; ++i )
|
||||
m[i] = load64( block + i * sizeof( m[i] ) );
|
||||
|
||||
for( i = 0; i < 8; ++i )
|
||||
v[i] = S->h[i];
|
||||
|
||||
v[ 8] = blake2b_IV[0];
|
||||
v[ 9] = blake2b_IV[1];
|
||||
v[10] = blake2b_IV[2];
|
||||
v[11] = blake2b_IV[3];
|
||||
v[12] = S->t[0] ^ blake2b_IV[4];
|
||||
v[13] = S->t[1] ^ blake2b_IV[5];
|
||||
v[14] = S->f[0] ^ blake2b_IV[6];
|
||||
v[15] = S->f[1] ^ blake2b_IV[7];
|
||||
#define G(r,i,a,b,c,d) \
|
||||
do { \
|
||||
a = a + b + m[blake2b_sigma[r][2*i+0]]; \
|
||||
d = rotr64(d ^ a, 32); \
|
||||
c = c + d; \
|
||||
b = rotr64(b ^ c, 24); \
|
||||
a = a + b + m[blake2b_sigma[r][2*i+1]]; \
|
||||
d = rotr64(d ^ a, 16); \
|
||||
c = c + d; \
|
||||
b = rotr64(b ^ c, 63); \
|
||||
} while(0)
|
||||
#define ROUND(r) \
|
||||
do { \
|
||||
G(r,0,v[ 0],v[ 4],v[ 8],v[12]); \
|
||||
G(r,1,v[ 1],v[ 5],v[ 9],v[13]); \
|
||||
G(r,2,v[ 2],v[ 6],v[10],v[14]); \
|
||||
G(r,3,v[ 3],v[ 7],v[11],v[15]); \
|
||||
G(r,4,v[ 0],v[ 5],v[10],v[15]); \
|
||||
G(r,5,v[ 1],v[ 6],v[11],v[12]); \
|
||||
G(r,6,v[ 2],v[ 7],v[ 8],v[13]); \
|
||||
G(r,7,v[ 3],v[ 4],v[ 9],v[14]); \
|
||||
} while(0)
|
||||
ROUND( 0 );
|
||||
ROUND( 1 );
|
||||
ROUND( 2 );
|
||||
ROUND( 3 );
|
||||
ROUND( 4 );
|
||||
ROUND( 5 );
|
||||
ROUND( 6 );
|
||||
ROUND( 7 );
|
||||
ROUND( 8 );
|
||||
ROUND( 9 );
|
||||
ROUND( 10 );
|
||||
ROUND( 11 );
|
||||
|
||||
for( i = 0; i < 8; ++i )
|
||||
S->h[i] = S->h[i] ^ v[i] ^ v[i + 8];
|
||||
|
||||
#undef G
|
||||
#undef ROUND
|
||||
|
||||
#ifdef WOLFSSL_SMALL_STACK
|
||||
XFREE(m, NULL, DYNAMIC_TYPE_TMP_BUFFER);
|
||||
XFREE(v, NULL, DYNAMIC_TYPE_TMP_BUFFER);
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* inlen now in bytes */
|
||||
int blake2b_update( blake2b_state *S, const byte *in, word64 inlen )
|
||||
{
|
||||
while( inlen > 0 )
|
||||
{
|
||||
word64 left = S->buflen;
|
||||
word64 fill = 2 * BLAKE2B_BLOCKBYTES - left;
|
||||
|
||||
if( inlen > fill )
|
||||
{
|
||||
XMEMCPY( S->buf + left, in, (wolfssl_word)fill ); /* Fill buffer */
|
||||
S->buflen += fill;
|
||||
blake2b_increment_counter( S, BLAKE2B_BLOCKBYTES );
|
||||
|
||||
if ( blake2b_compress( S, S->buf ) < 0 ) return -1; /* Compress */
|
||||
|
||||
XMEMCPY( S->buf, S->buf + BLAKE2B_BLOCKBYTES, BLAKE2B_BLOCKBYTES );
|
||||
/* Shift buffer left */
|
||||
S->buflen -= BLAKE2B_BLOCKBYTES;
|
||||
in += fill;
|
||||
inlen -= fill;
|
||||
}
|
||||
else /* inlen <= fill */
|
||||
{
|
||||
XMEMCPY( S->buf + left, in, (wolfssl_word)inlen );
|
||||
S->buflen += inlen; /* Be lazy, do not compress */
|
||||
inlen = 0;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Is this correct? */
|
||||
int blake2b_final( blake2b_state *S, byte *out, byte outlen )
|
||||
{
|
||||
byte buffer[BLAKE2B_OUTBYTES];
|
||||
int i;
|
||||
|
||||
if( S->buflen > BLAKE2B_BLOCKBYTES )
|
||||
{
|
||||
blake2b_increment_counter( S, BLAKE2B_BLOCKBYTES );
|
||||
|
||||
if ( blake2b_compress( S, S->buf ) < 0 ) return -1;
|
||||
|
||||
S->buflen -= BLAKE2B_BLOCKBYTES;
|
||||
XMEMCPY( S->buf, S->buf + BLAKE2B_BLOCKBYTES, (wolfssl_word)S->buflen );
|
||||
}
|
||||
|
||||
blake2b_increment_counter( S, S->buflen );
|
||||
blake2b_set_lastblock( S );
|
||||
XMEMSET( S->buf + S->buflen, 0, (wolfssl_word)(2 * BLAKE2B_BLOCKBYTES - S->buflen) );
|
||||
/* Padding */
|
||||
if ( blake2b_compress( S, S->buf ) < 0 ) return -1;
|
||||
|
||||
for( i = 0; i < 8; ++i ) /* Output full hash to temp buffer */
|
||||
store64( buffer + sizeof( S->h[i] ) * i, S->h[i] );
|
||||
|
||||
XMEMCPY( out, buffer, outlen );
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* inlen, at least, should be word64. Others can be size_t. */
|
||||
int blake2b( byte *out, const void *in, const void *key, const byte outlen,
|
||||
const word64 inlen, byte keylen )
|
||||
{
|
||||
blake2b_state S[1];
|
||||
|
||||
/* Verify parameters */
|
||||
if ( NULL == in ) return -1;
|
||||
|
||||
if ( NULL == out ) return -1;
|
||||
|
||||
if( NULL == key ) keylen = 0;
|
||||
|
||||
if( keylen > 0 )
|
||||
{
|
||||
if( blake2b_init_key( S, outlen, key, keylen ) < 0 ) return -1;
|
||||
}
|
||||
else
|
||||
{
|
||||
if( blake2b_init( S, outlen ) < 0 ) return -1;
|
||||
}
|
||||
|
||||
if ( blake2b_update( S, ( byte * )in, inlen ) < 0) return -1;
|
||||
|
||||
return blake2b_final( S, out, outlen );
|
||||
}
|
||||
|
||||
#if defined(BLAKE2B_SELFTEST)
|
||||
#include <string.h>
|
||||
#include "blake2-kat.h"
|
||||
int main( int argc, char **argv )
|
||||
{
|
||||
byte key[BLAKE2B_KEYBYTES];
|
||||
byte buf[KAT_LENGTH];
|
||||
|
||||
for( word32 i = 0; i < BLAKE2B_KEYBYTES; ++i )
|
||||
key[i] = ( byte )i;
|
||||
|
||||
for( word32 i = 0; i < KAT_LENGTH; ++i )
|
||||
buf[i] = ( byte )i;
|
||||
|
||||
for( word32 i = 0; i < KAT_LENGTH; ++i )
|
||||
{
|
||||
byte hash[BLAKE2B_OUTBYTES];
|
||||
if ( blake2b( hash, buf, key, BLAKE2B_OUTBYTES, i, BLAKE2B_KEYBYTES ) < 0 )
|
||||
{
|
||||
puts( "error" );
|
||||
return -1;
|
||||
}
|
||||
|
||||
if( 0 != XMEMCMP( hash, blake2b_keyed_kat[i], BLAKE2B_OUTBYTES ) )
|
||||
{
|
||||
puts( "error" );
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
puts( "ok" );
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
/* wolfCrypt API */
|
||||
|
||||
/* Init Blake2b digest, track size in case final doesn't want to "remember" */
|
||||
int wc_InitBlake2b(Blake2b* b2b, word32 digestSz)
|
||||
{
|
||||
if (b2b == NULL){
|
||||
return -1;
|
||||
}
|
||||
b2b->digestSz = digestSz;
|
||||
|
||||
return blake2b_init(b2b->S, (byte)digestSz);
|
||||
}
|
||||
|
||||
|
||||
/* Blake2b Update */
|
||||
int wc_Blake2bUpdate(Blake2b* b2b, const byte* data, word32 sz)
|
||||
{
|
||||
return blake2b_update(b2b->S, data, sz);
|
||||
}
|
||||
|
||||
|
||||
/* Blake2b Final, if pass in zero size we use init digestSz */
|
||||
int wc_Blake2bFinal(Blake2b* b2b, byte* final, word32 requestSz)
|
||||
{
|
||||
word32 sz = requestSz ? requestSz : b2b->digestSz;
|
||||
|
||||
return blake2b_final(b2b->S, final, (byte)sz);
|
||||
}
|
||||
|
||||
|
||||
/* end CTaoCrypt API */
|
||||
|
||||
#endif /* HAVE_BLAKE2 */
|
||||
|
@ -1,446 +0,0 @@
|
||||
/*
|
||||
BLAKE2 reference source code package - reference C implementations
|
||||
|
||||
Written in 2012 by Samuel Neves <sneves@dei.uc.pt>
|
||||
|
||||
To the extent possible under law, the author(s) have dedicated all copyright
|
||||
and related and neighboring rights to this software to the public domain
|
||||
worldwide. This software is distributed without any warranty.
|
||||
|
||||
You should have received a copy of the CC0 Public Domain Dedication along with
|
||||
this software. If not, see <http://creativecommons.org/publicdomain/zero/1.0/>.
|
||||
*/
|
||||
/* blake2s.c
|
||||
*
|
||||
* Copyright (C) 2006-2020 wolfSSL Inc.
|
||||
*
|
||||
* This file is part of wolfSSL.
|
||||
*
|
||||
* wolfSSL is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* wolfSSL is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA
|
||||
*/
|
||||
|
||||
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
#endif
|
||||
|
||||
#include <wolfssl/wolfcrypt/settings.h>
|
||||
|
||||
#ifdef HAVE_BLAKE2S
|
||||
|
||||
#include <wolfssl/wolfcrypt/blake2.h>
|
||||
#include <wolfssl/wolfcrypt/blake2-impl.h>
|
||||
|
||||
|
||||
static const word32 blake2s_IV[8] =
|
||||
{
|
||||
0x6a09e667, 0xbb67ae85, 0x3c6ef372, 0xa54ff53a,
|
||||
0x510e527f, 0x9b05688c, 0x1f83d9ab, 0x5be0cd19
|
||||
};
|
||||
|
||||
static const byte blake2s_sigma[10][16] =
|
||||
{
|
||||
{ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 } ,
|
||||
{ 14, 10, 4, 8, 9, 15, 13, 6, 1, 12, 0, 2, 11, 7, 5, 3 } ,
|
||||
{ 11, 8, 12, 0, 5, 2, 15, 13, 10, 14, 3, 6, 7, 1, 9, 4 } ,
|
||||
{ 7, 9, 3, 1, 13, 12, 11, 14, 2, 6, 5, 10, 4, 0, 15, 8 } ,
|
||||
{ 9, 0, 5, 7, 2, 4, 10, 15, 14, 1, 11, 12, 6, 8, 3, 13 } ,
|
||||
{ 2, 12, 6, 10, 0, 11, 8, 3, 4, 13, 7, 5, 15, 14, 1, 9 } ,
|
||||
{ 12, 5, 1, 15, 14, 13, 4, 10, 0, 7, 6, 3, 9, 2, 8, 11 } ,
|
||||
{ 13, 11, 7, 14, 12, 1, 3, 9, 5, 0, 15, 4, 8, 6, 2, 10 } ,
|
||||
{ 6, 15, 14, 9, 11, 3, 0, 8, 12, 2, 13, 7, 1, 4, 10, 5 } ,
|
||||
{ 10, 2, 8, 4, 7, 6, 1, 5, 15, 11, 9, 14, 3, 12, 13 , 0 }
|
||||
};
|
||||
|
||||
|
||||
static WC_INLINE int blake2s_set_lastnode( blake2s_state *S )
|
||||
{
|
||||
S->f[1] = ~0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Some helper functions, not necessarily useful */
|
||||
static WC_INLINE int blake2s_set_lastblock( blake2s_state *S )
|
||||
{
|
||||
if( S->last_node ) blake2s_set_lastnode( S );
|
||||
|
||||
S->f[0] = ~0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static WC_INLINE int blake2s_increment_counter( blake2s_state *S, const word32
|
||||
inc )
|
||||
{
|
||||
S->t[0] += inc;
|
||||
S->t[1] += ( S->t[0] < inc );
|
||||
return 0;
|
||||
}
|
||||
|
||||
static WC_INLINE int blake2s_init0( blake2s_state *S )
|
||||
{
|
||||
int i;
|
||||
XMEMSET( S, 0, sizeof( blake2s_state ) );
|
||||
|
||||
for( i = 0; i < 8; ++i ) S->h[i] = blake2s_IV[i];
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* init xors IV with input parameter block */
|
||||
int blake2s_init_param( blake2s_state *S, const blake2s_param *P )
|
||||
{
|
||||
word32 i;
|
||||
byte *p ;
|
||||
blake2s_init0( S );
|
||||
p = ( byte * )( P );
|
||||
|
||||
/* IV XOR ParamBlock */
|
||||
for( i = 0; i < 8; ++i )
|
||||
S->h[i] ^= load32( p + sizeof( S->h[i] ) * i );
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
int blake2s_init( blake2s_state *S, const byte outlen )
|
||||
{
|
||||
blake2s_param P[1];
|
||||
|
||||
if ( ( !outlen ) || ( outlen > BLAKE2S_OUTBYTES ) ) return -1;
|
||||
|
||||
#ifdef WOLFSSL_BLAKE2S_INIT_EACH_FIELD
|
||||
P->digest_length = outlen;
|
||||
P->key_length = 0;
|
||||
P->fanout = 1;
|
||||
P->depth = 1;
|
||||
store32( &P->leaf_length, 0 );
|
||||
store32( &P->node_offset, 0 );
|
||||
P->node_depth = 0;
|
||||
P->inner_length = 0;
|
||||
XMEMSET( P->reserved, 0, sizeof( P->reserved ) );
|
||||
XMEMSET( P->salt, 0, sizeof( P->salt ) );
|
||||
XMEMSET( P->personal, 0, sizeof( P->personal ) );
|
||||
#else
|
||||
XMEMSET( P, 0, sizeof( *P ) );
|
||||
P->digest_length = outlen;
|
||||
P->fanout = 1;
|
||||
P->depth = 1;
|
||||
#endif
|
||||
return blake2s_init_param( S, P );
|
||||
}
|
||||
|
||||
|
||||
int blake2s_init_key( blake2s_state *S, const byte outlen, const void *key,
|
||||
const byte keylen )
|
||||
{
|
||||
blake2s_param P[1];
|
||||
|
||||
if ( ( !outlen ) || ( outlen > BLAKE2S_OUTBYTES ) ) return -1;
|
||||
|
||||
if ( !key || !keylen || keylen > BLAKE2S_KEYBYTES ) return -1;
|
||||
|
||||
#ifdef WOLFSSL_BLAKE2S_INIT_EACH_FIELD
|
||||
P->digest_length = outlen;
|
||||
P->key_length = keylen;
|
||||
P->fanout = 1;
|
||||
P->depth = 1;
|
||||
store32( &P->leaf_length, 0 );
|
||||
store64( &P->node_offset, 0 );
|
||||
P->node_depth = 0;
|
||||
P->inner_length = 0;
|
||||
XMEMSET( P->reserved, 0, sizeof( P->reserved ) );
|
||||
XMEMSET( P->salt, 0, sizeof( P->salt ) );
|
||||
XMEMSET( P->personal, 0, sizeof( P->personal ) );
|
||||
#else
|
||||
XMEMSET( P, 0, sizeof( *P ) );
|
||||
P->digest_length = outlen;
|
||||
P->key_length = keylen;
|
||||
P->fanout = 1;
|
||||
P->depth = 1;
|
||||
#endif
|
||||
|
||||
if( blake2s_init_param( S, P ) < 0 ) return -1;
|
||||
|
||||
{
|
||||
#ifdef WOLFSSL_SMALL_STACK
|
||||
byte* block;
|
||||
|
||||
block = (byte*)XMALLOC(BLAKE2S_BLOCKBYTES, NULL, DYNAMIC_TYPE_TMP_BUFFER);
|
||||
|
||||
if ( block == NULL ) return -1;
|
||||
#else
|
||||
byte block[BLAKE2S_BLOCKBYTES];
|
||||
#endif
|
||||
|
||||
XMEMSET( block, 0, BLAKE2S_BLOCKBYTES );
|
||||
XMEMCPY( block, key, keylen );
|
||||
blake2s_update( S, block, BLAKE2S_BLOCKBYTES );
|
||||
secure_zero_memory( block, BLAKE2S_BLOCKBYTES ); /* Burn the key from */
|
||||
/* memory */
|
||||
|
||||
#ifdef WOLFSSL_SMALL_STACK
|
||||
XFREE(block, NULL, DYNAMIC_TYPE_TMP_BUFFER);
|
||||
#endif
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int blake2s_compress( blake2s_state *S,
|
||||
const byte block[BLAKE2S_BLOCKBYTES] )
|
||||
{
|
||||
int i;
|
||||
|
||||
#ifdef WOLFSSL_SMALL_STACK
|
||||
word32* m;
|
||||
word32* v;
|
||||
|
||||
m = (word32*)XMALLOC(sizeof(word32) * 16, NULL, DYNAMIC_TYPE_TMP_BUFFER);
|
||||
|
||||
if ( m == NULL ) return -1;
|
||||
|
||||
v = (word32*)XMALLOC(sizeof(word32) * 16, NULL, DYNAMIC_TYPE_TMP_BUFFER);
|
||||
|
||||
if ( v == NULL )
|
||||
{
|
||||
XFREE(m, NULL, DYNAMIC_TYPE_TMP_BUFFER);
|
||||
return -1;
|
||||
}
|
||||
#else
|
||||
word32 m[16];
|
||||
word32 v[16];
|
||||
#endif
|
||||
|
||||
for( i = 0; i < 16; ++i )
|
||||
m[i] = load32( block + i * sizeof( m[i] ) );
|
||||
|
||||
for( i = 0; i < 8; ++i )
|
||||
v[i] = S->h[i];
|
||||
|
||||
v[ 8] = blake2s_IV[0];
|
||||
v[ 9] = blake2s_IV[1];
|
||||
v[10] = blake2s_IV[2];
|
||||
v[11] = blake2s_IV[3];
|
||||
v[12] = S->t[0] ^ blake2s_IV[4];
|
||||
v[13] = S->t[1] ^ blake2s_IV[5];
|
||||
v[14] = S->f[0] ^ blake2s_IV[6];
|
||||
v[15] = S->f[1] ^ blake2s_IV[7];
|
||||
#define G(r,i,a,b,c,d) \
|
||||
do { \
|
||||
a = a + b + m[blake2s_sigma[r][2*i+0]]; \
|
||||
d = rotr32(d ^ a, 16); \
|
||||
c = c + d; \
|
||||
b = rotr32(b ^ c, 12); \
|
||||
a = a + b + m[blake2s_sigma[r][2*i+1]]; \
|
||||
d = rotr32(d ^ a, 8); \
|
||||
c = c + d; \
|
||||
b = rotr32(b ^ c, 7); \
|
||||
} while(0)
|
||||
#define ROUND(r) \
|
||||
do { \
|
||||
G(r,0,v[ 0],v[ 4],v[ 8],v[12]); \
|
||||
G(r,1,v[ 1],v[ 5],v[ 9],v[13]); \
|
||||
G(r,2,v[ 2],v[ 6],v[10],v[14]); \
|
||||
G(r,3,v[ 3],v[ 7],v[11],v[15]); \
|
||||
G(r,4,v[ 0],v[ 5],v[10],v[15]); \
|
||||
G(r,5,v[ 1],v[ 6],v[11],v[12]); \
|
||||
G(r,6,v[ 2],v[ 7],v[ 8],v[13]); \
|
||||
G(r,7,v[ 3],v[ 4],v[ 9],v[14]); \
|
||||
} while(0)
|
||||
ROUND( 0 );
|
||||
ROUND( 1 );
|
||||
ROUND( 2 );
|
||||
ROUND( 3 );
|
||||
ROUND( 4 );
|
||||
ROUND( 5 );
|
||||
ROUND( 6 );
|
||||
ROUND( 7 );
|
||||
ROUND( 8 );
|
||||
ROUND( 9 );
|
||||
|
||||
for( i = 0; i < 8; ++i )
|
||||
S->h[i] = S->h[i] ^ v[i] ^ v[i + 8];
|
||||
|
||||
#undef G
|
||||
#undef ROUND
|
||||
|
||||
#ifdef WOLFSSL_SMALL_STACK
|
||||
XFREE(m, NULL, DYNAMIC_TYPE_TMP_BUFFER);
|
||||
XFREE(v, NULL, DYNAMIC_TYPE_TMP_BUFFER);
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* inlen now in bytes */
|
||||
int blake2s_update( blake2s_state *S, const byte *in, word32 inlen )
|
||||
{
|
||||
while( inlen > 0 )
|
||||
{
|
||||
word32 left = S->buflen;
|
||||
word32 fill = 2 * BLAKE2S_BLOCKBYTES - left;
|
||||
|
||||
if( inlen > fill )
|
||||
{
|
||||
XMEMCPY( S->buf + left, in, (wolfssl_word)fill ); /* Fill buffer */
|
||||
S->buflen += fill;
|
||||
blake2s_increment_counter( S, BLAKE2S_BLOCKBYTES );
|
||||
|
||||
if ( blake2s_compress( S, S->buf ) < 0 ) return -1; /* Compress */
|
||||
|
||||
XMEMCPY( S->buf, S->buf + BLAKE2S_BLOCKBYTES, BLAKE2S_BLOCKBYTES );
|
||||
/* Shift buffer left */
|
||||
S->buflen -= BLAKE2S_BLOCKBYTES;
|
||||
in += fill;
|
||||
inlen -= fill;
|
||||
}
|
||||
else /* inlen <= fill */
|
||||
{
|
||||
XMEMCPY( S->buf + left, in, (wolfssl_word)inlen );
|
||||
S->buflen += inlen; /* Be lazy, do not compress */
|
||||
inlen = 0;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Is this correct? */
|
||||
int blake2s_final( blake2s_state *S, byte *out, byte outlen )
|
||||
{
|
||||
int i;
|
||||
byte buffer[BLAKE2S_BLOCKBYTES];
|
||||
|
||||
if( S->buflen > BLAKE2S_BLOCKBYTES )
|
||||
{
|
||||
blake2s_increment_counter( S, BLAKE2S_BLOCKBYTES );
|
||||
|
||||
if ( blake2s_compress( S, S->buf ) < 0 ) return -1;
|
||||
|
||||
S->buflen -= BLAKE2S_BLOCKBYTES;
|
||||
XMEMCPY( S->buf, S->buf + BLAKE2S_BLOCKBYTES, (wolfssl_word)S->buflen );
|
||||
}
|
||||
|
||||
blake2s_increment_counter( S, S->buflen );
|
||||
blake2s_set_lastblock( S );
|
||||
XMEMSET( S->buf + S->buflen, 0, (wolfssl_word)(2 * BLAKE2S_BLOCKBYTES - S->buflen) );
|
||||
/* Padding */
|
||||
if ( blake2s_compress( S, S->buf ) < 0 ) return -1;
|
||||
|
||||
for( i = 0; i < 8; ++i ) /* Output full hash to temp buffer */
|
||||
store64( buffer + sizeof( S->h[i] ) * i, S->h[i] );
|
||||
|
||||
XMEMCPY( out, buffer, outlen );
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* inlen, at least, should be word32. Others can be size_t. */
|
||||
int blake2s( byte *out, const void *in, const void *key, const byte outlen,
|
||||
const word32 inlen, byte keylen )
|
||||
{
|
||||
blake2s_state S[1];
|
||||
|
||||
/* Verify parameters */
|
||||
if ( NULL == in ) return -1;
|
||||
|
||||
if ( NULL == out ) return -1;
|
||||
|
||||
if( NULL == key ) keylen = 0;
|
||||
|
||||
if( keylen > 0 )
|
||||
{
|
||||
if( blake2s_init_key( S, outlen, key, keylen ) < 0 ) return -1;
|
||||
}
|
||||
else
|
||||
{
|
||||
if( blake2s_init( S, outlen ) < 0 ) return -1;
|
||||
}
|
||||
|
||||
if ( blake2s_update( S, ( byte * )in, inlen ) < 0) return -1;
|
||||
|
||||
return blake2s_final( S, out, outlen );
|
||||
}
|
||||
|
||||
#if defined(BLAKE2S_SELFTEST)
|
||||
#include <string.h>
|
||||
#include "blake2-kat.h"
|
||||
int main( int argc, char **argv )
|
||||
{
|
||||
byte key[BLAKE2S_KEYBYTES];
|
||||
byte buf[KAT_LENGTH];
|
||||
|
||||
for( word32 i = 0; i < BLAKE2S_KEYBYTES; ++i )
|
||||
key[i] = ( byte )i;
|
||||
|
||||
for( word32 i = 0; i < KAT_LENGTH; ++i )
|
||||
buf[i] = ( byte )i;
|
||||
|
||||
for( word32 i = 0; i < KAT_LENGTH; ++i )
|
||||
{
|
||||
byte hash[BLAKE2S_OUTBYTES];
|
||||
if ( blake2s( hash, buf, key, BLAKE2S_OUTBYTES, i, BLAKE2S_KEYBYTES ) < 0 )
|
||||
{
|
||||
puts( "error" );
|
||||
return -1;
|
||||
}
|
||||
|
||||
if( 0 != XMEMCMP( hash, blake2s_keyed_kat[i], BLAKE2S_OUTBYTES ) )
|
||||
{
|
||||
puts( "error" );
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
puts( "ok" );
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
/* wolfCrypt API */
|
||||
|
||||
/* Init Blake2s digest, track size in case final doesn't want to "remember" */
|
||||
int wc_InitBlake2s(Blake2s* b2s, word32 digestSz)
|
||||
{
|
||||
if (b2s == NULL){
|
||||
return -1;
|
||||
}
|
||||
b2s->digestSz = digestSz;
|
||||
|
||||
return blake2s_init(b2s->S, (byte)digestSz);
|
||||
}
|
||||
|
||||
|
||||
/* Blake2s Update */
|
||||
int wc_Blake2sUpdate(Blake2s* b2s, const byte* data, word32 sz)
|
||||
{
|
||||
return blake2s_update(b2s->S, data, sz);
|
||||
}
|
||||
|
||||
|
||||
/* Blake2s Final, if pass in zero size we use init digestSz */
|
||||
int wc_Blake2sFinal(Blake2s* b2s, byte* final, word32 requestSz)
|
||||
{
|
||||
word32 sz = requestSz ? requestSz : b2s->digestSz;
|
||||
|
||||
return blake2s_final(b2s->S, final, (byte)sz);
|
||||
}
|
||||
|
||||
|
||||
/* end CTaoCrypt API */
|
||||
|
||||
#endif /* HAVE_BLAKE2S */
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -1,341 +0,0 @@
|
||||
/* chacha.c
|
||||
*
|
||||
* Copyright (C) 2006-2020 wolfSSL Inc.
|
||||
*
|
||||
* This file is part of wolfSSL.
|
||||
*
|
||||
* wolfSSL is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* wolfSSL is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA
|
||||
*/
|
||||
/*
|
||||
|
||||
DESCRIPTION
|
||||
This library contains implementation for the ChaCha20 stream cipher.
|
||||
|
||||
Based from chacha-ref.c version 20080118
|
||||
D. J. Bernstein
|
||||
Public domain.
|
||||
|
||||
*/
|
||||
#ifdef WOLFSSL_ARMASM
|
||||
/* implementation is located in wolfcrypt/src/port/arm/armv8-chacha.c */
|
||||
|
||||
#else
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
#endif
|
||||
|
||||
#include <wolfssl/wolfcrypt/settings.h>
|
||||
|
||||
#if defined(HAVE_CHACHA) && !defined(WOLFSSL_ARMASM)
|
||||
|
||||
#include <wolfssl/wolfcrypt/chacha.h>
|
||||
#include <wolfssl/wolfcrypt/error-crypt.h>
|
||||
#include <wolfssl/wolfcrypt/logging.h>
|
||||
#include <wolfssl/wolfcrypt/cpuid.h>
|
||||
#ifdef NO_INLINE
|
||||
#include <wolfssl/wolfcrypt/misc.h>
|
||||
#else
|
||||
#define WOLFSSL_MISC_INCLUDED
|
||||
#include <wolfcrypt/src/misc.c>
|
||||
#endif
|
||||
|
||||
#ifdef CHACHA_AEAD_TEST
|
||||
#include <stdio.h>
|
||||
#endif
|
||||
|
||||
#ifdef USE_INTEL_CHACHA_SPEEDUP
|
||||
#include <emmintrin.h>
|
||||
#include <immintrin.h>
|
||||
|
||||
#if defined(__GNUC__) && ((__GNUC__ < 4) || \
|
||||
(__GNUC__ == 4 && __GNUC_MINOR__ <= 8))
|
||||
#undef NO_AVX2_SUPPORT
|
||||
#define NO_AVX2_SUPPORT
|
||||
#endif
|
||||
#if defined(__clang__) && ((__clang_major__ < 3) || \
|
||||
(__clang_major__ == 3 && __clang_minor__ <= 5))
|
||||
#undef NO_AVX2_SUPPORT
|
||||
#define NO_AVX2_SUPPORT
|
||||
#elif defined(__clang__) && defined(NO_AVX2_SUPPORT)
|
||||
#undef NO_AVX2_SUPPORT
|
||||
#endif
|
||||
|
||||
#ifndef NO_AVX2_SUPPORT
|
||||
#define HAVE_INTEL_AVX2
|
||||
#endif
|
||||
|
||||
static int cpuidFlagsSet = 0;
|
||||
static int cpuidFlags = 0;
|
||||
#endif
|
||||
|
||||
#ifdef BIG_ENDIAN_ORDER
|
||||
#define LITTLE32(x) ByteReverseWord32(x)
|
||||
#else
|
||||
#define LITTLE32(x) (x)
|
||||
#endif
|
||||
|
||||
/* Number of rounds */
|
||||
#define ROUNDS 20
|
||||
|
||||
#define U32C(v) (v##U)
|
||||
#define U32V(v) ((word32)(v) & U32C(0xFFFFFFFF))
|
||||
#define U8TO32_LITTLE(p) LITTLE32(((word32*)(p))[0])
|
||||
|
||||
#define ROTATE(v,c) rotlFixed(v, c)
|
||||
#define XOR(v,w) ((v) ^ (w))
|
||||
#define PLUS(v,w) (U32V((v) + (w)))
|
||||
#define PLUSONE(v) (PLUS((v),1))
|
||||
|
||||
#define QUARTERROUND(a,b,c,d) \
|
||||
x[a] = PLUS(x[a],x[b]); x[d] = ROTATE(XOR(x[d],x[a]),16); \
|
||||
x[c] = PLUS(x[c],x[d]); x[b] = ROTATE(XOR(x[b],x[c]),12); \
|
||||
x[a] = PLUS(x[a],x[b]); x[d] = ROTATE(XOR(x[d],x[a]), 8); \
|
||||
x[c] = PLUS(x[c],x[d]); x[b] = ROTATE(XOR(x[b],x[c]), 7);
|
||||
|
||||
|
||||
/**
|
||||
* Set up iv(nonce). Earlier versions used 64 bits instead of 96, this version
|
||||
* uses the typical AEAD 96 bit nonce and can do record sizes of 256 GB.
|
||||
*/
|
||||
int wc_Chacha_SetIV(ChaCha* ctx, const byte* inIv, word32 counter)
|
||||
{
|
||||
word32 temp[CHACHA_IV_WORDS];/* used for alignment of memory */
|
||||
|
||||
|
||||
if (ctx == NULL || inIv == NULL)
|
||||
return BAD_FUNC_ARG;
|
||||
|
||||
XMEMCPY(temp, inIv, CHACHA_IV_BYTES);
|
||||
|
||||
ctx->left = 0; /* resets state */
|
||||
ctx->X[CHACHA_MATRIX_CNT_IV+0] = counter; /* block counter */
|
||||
ctx->X[CHACHA_MATRIX_CNT_IV+1] = LITTLE32(temp[0]); /* fixed variable from nonce */
|
||||
ctx->X[CHACHA_MATRIX_CNT_IV+2] = LITTLE32(temp[1]); /* counter from nonce */
|
||||
ctx->X[CHACHA_MATRIX_CNT_IV+3] = LITTLE32(temp[2]); /* counter from nonce */
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* "expand 32-byte k" as unsigned 32 byte */
|
||||
static const word32 sigma[4] = {0x61707865, 0x3320646e, 0x79622d32, 0x6b206574};
|
||||
/* "expand 16-byte k" as unsigned 16 byte */
|
||||
static const word32 tau[4] = {0x61707865, 0x3120646e, 0x79622d36, 0x6b206574};
|
||||
|
||||
/**
|
||||
* Key setup. 8 word iv (nonce)
|
||||
*/
|
||||
int wc_Chacha_SetKey(ChaCha* ctx, const byte* key, word32 keySz)
|
||||
{
|
||||
const word32* constants;
|
||||
const byte* k;
|
||||
|
||||
#ifdef XSTREAM_ALIGN
|
||||
word32 alignKey[8];
|
||||
#endif
|
||||
|
||||
if (ctx == NULL || key == NULL)
|
||||
return BAD_FUNC_ARG;
|
||||
|
||||
if (keySz != (CHACHA_MAX_KEY_SZ/2) && keySz != CHACHA_MAX_KEY_SZ)
|
||||
return BAD_FUNC_ARG;
|
||||
|
||||
#ifdef XSTREAM_ALIGN
|
||||
if ((wolfssl_word)key % 4) {
|
||||
WOLFSSL_MSG("wc_ChachaSetKey unaligned key");
|
||||
XMEMCPY(alignKey, key, keySz);
|
||||
k = (byte*)alignKey;
|
||||
}
|
||||
else {
|
||||
k = key;
|
||||
}
|
||||
#else
|
||||
k = key;
|
||||
#endif /* XSTREAM_ALIGN */
|
||||
|
||||
#ifdef CHACHA_AEAD_TEST
|
||||
word32 i;
|
||||
printf("ChaCha key used :\n");
|
||||
for (i = 0; i < keySz; i++) {
|
||||
printf("%02x", key[i]);
|
||||
if ((i + 1) % 8 == 0)
|
||||
printf("\n");
|
||||
}
|
||||
printf("\n\n");
|
||||
#endif
|
||||
|
||||
ctx->X[4] = U8TO32_LITTLE(k + 0);
|
||||
ctx->X[5] = U8TO32_LITTLE(k + 4);
|
||||
ctx->X[6] = U8TO32_LITTLE(k + 8);
|
||||
ctx->X[7] = U8TO32_LITTLE(k + 12);
|
||||
if (keySz == CHACHA_MAX_KEY_SZ) {
|
||||
k += 16;
|
||||
constants = sigma;
|
||||
}
|
||||
else {
|
||||
constants = tau;
|
||||
}
|
||||
ctx->X[ 8] = U8TO32_LITTLE(k + 0);
|
||||
ctx->X[ 9] = U8TO32_LITTLE(k + 4);
|
||||
ctx->X[10] = U8TO32_LITTLE(k + 8);
|
||||
ctx->X[11] = U8TO32_LITTLE(k + 12);
|
||||
ctx->X[ 0] = constants[0];
|
||||
ctx->X[ 1] = constants[1];
|
||||
ctx->X[ 2] = constants[2];
|
||||
ctx->X[ 3] = constants[3];
|
||||
ctx->left = 0; /* resets state */
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts word into bytes with rotations having been done.
|
||||
*/
|
||||
static WC_INLINE void wc_Chacha_wordtobyte(word32 output[CHACHA_CHUNK_WORDS],
|
||||
const word32 input[CHACHA_CHUNK_WORDS])
|
||||
{
|
||||
word32 x[CHACHA_CHUNK_WORDS];
|
||||
word32 i;
|
||||
|
||||
for (i = 0; i < CHACHA_CHUNK_WORDS; i++) {
|
||||
x[i] = input[i];
|
||||
}
|
||||
|
||||
for (i = (ROUNDS); i > 0; i -= 2) {
|
||||
QUARTERROUND(0, 4, 8, 12)
|
||||
QUARTERROUND(1, 5, 9, 13)
|
||||
QUARTERROUND(2, 6, 10, 14)
|
||||
QUARTERROUND(3, 7, 11, 15)
|
||||
QUARTERROUND(0, 5, 10, 15)
|
||||
QUARTERROUND(1, 6, 11, 12)
|
||||
QUARTERROUND(2, 7, 8, 13)
|
||||
QUARTERROUND(3, 4, 9, 14)
|
||||
}
|
||||
|
||||
for (i = 0; i < CHACHA_CHUNK_WORDS; i++) {
|
||||
x[i] = PLUS(x[i], input[i]);
|
||||
}
|
||||
|
||||
for (i = 0; i < CHACHA_CHUNK_WORDS; i++) {
|
||||
output[i] = LITTLE32(x[i]);
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
extern void chacha_encrypt_x64(ChaCha* ctx, const byte* m, byte* c,
|
||||
word32 bytes);
|
||||
extern void chacha_encrypt_avx1(ChaCha* ctx, const byte* m, byte* c,
|
||||
word32 bytes);
|
||||
extern void chacha_encrypt_avx2(ChaCha* ctx, const byte* m, byte* c,
|
||||
word32 bytes);
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
|
||||
|
||||
/**
|
||||
* Encrypt a stream of bytes
|
||||
*/
|
||||
static void wc_Chacha_encrypt_bytes(ChaCha* ctx, const byte* m, byte* c,
|
||||
word32 bytes)
|
||||
{
|
||||
byte* output;
|
||||
word32 temp[CHACHA_CHUNK_WORDS]; /* used to make sure aligned */
|
||||
word32 i;
|
||||
|
||||
/* handle left overs */
|
||||
if (bytes > 0 && ctx->left > 0) {
|
||||
wc_Chacha_wordtobyte(temp, ctx->X); /* recreate the stream */
|
||||
output = (byte*)temp + CHACHA_CHUNK_BYTES - ctx->left;
|
||||
for (i = 0; i < bytes && i < ctx->left; i++) {
|
||||
c[i] = (byte)(m[i] ^ output[i]);
|
||||
}
|
||||
ctx->left = ctx->left - i;
|
||||
|
||||
/* Used up all of the stream that was left, increment the counter */
|
||||
if (ctx->left == 0) {
|
||||
ctx->X[CHACHA_MATRIX_CNT_IV] = PLUSONE(ctx->X[CHACHA_MATRIX_CNT_IV]);
|
||||
}
|
||||
bytes = bytes - i;
|
||||
c += i;
|
||||
m += i;
|
||||
}
|
||||
|
||||
output = (byte*)temp;
|
||||
while (bytes >= CHACHA_CHUNK_BYTES) {
|
||||
wc_Chacha_wordtobyte(temp, ctx->X);
|
||||
ctx->X[CHACHA_MATRIX_CNT_IV] = PLUSONE(ctx->X[CHACHA_MATRIX_CNT_IV]);
|
||||
for (i = 0; i < CHACHA_CHUNK_BYTES; ++i) {
|
||||
c[i] = (byte)(m[i] ^ output[i]);
|
||||
}
|
||||
bytes -= CHACHA_CHUNK_BYTES;
|
||||
c += CHACHA_CHUNK_BYTES;
|
||||
m += CHACHA_CHUNK_BYTES;
|
||||
}
|
||||
|
||||
if (bytes) {
|
||||
/* in this case there will always be some left over since bytes is less
|
||||
* than CHACHA_CHUNK_BYTES, so do not increment counter after getting
|
||||
* stream in order for the stream to be recreated on next call */
|
||||
wc_Chacha_wordtobyte(temp, ctx->X);
|
||||
for (i = 0; i < bytes; ++i) {
|
||||
c[i] = m[i] ^ output[i];
|
||||
}
|
||||
ctx->left = CHACHA_CHUNK_BYTES - i;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* API to encrypt/decrypt a message of any size.
|
||||
*/
|
||||
int wc_Chacha_Process(ChaCha* ctx, byte* output, const byte* input,
|
||||
word32 msglen)
|
||||
{
|
||||
if (ctx == NULL || input == NULL || output == NULL)
|
||||
return BAD_FUNC_ARG;
|
||||
|
||||
#ifdef USE_INTEL_CHACHA_SPEEDUP
|
||||
if (!cpuidFlagsSet) {
|
||||
cpuidFlags = cpuid_get_flags();
|
||||
cpuidFlagsSet = 1;
|
||||
}
|
||||
|
||||
#ifdef HAVE_INTEL_AVX2
|
||||
if (IS_INTEL_AVX2(cpuidFlags)) {
|
||||
chacha_encrypt_avx2(ctx, input, output, msglen);
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
if (IS_INTEL_AVX1(cpuidFlags)) {
|
||||
chacha_encrypt_avx1(ctx, input, output, msglen);
|
||||
return 0;
|
||||
}
|
||||
else {
|
||||
chacha_encrypt_x64(ctx, input, output, msglen);
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
wc_Chacha_encrypt_bytes(ctx, input, output, msglen);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif /* HAVE_CHACHA*/
|
||||
|
||||
#endif /* WOLFSSL_ARMASM */
|
@ -1,296 +0,0 @@
|
||||
/* chacha.c
|
||||
*
|
||||
* Copyright (C) 2006-2020 wolfSSL Inc.
|
||||
*
|
||||
* This file is part of wolfSSL.
|
||||
*
|
||||
* wolfSSL is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* wolfSSL is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA
|
||||
*/
|
||||
/*
|
||||
|
||||
DESCRIPTION
|
||||
This library contains implementation for the ChaCha20 stream cipher and
|
||||
the Poly1305 authenticator, both as as combined-mode,
|
||||
or Authenticated Encryption with Additional Data (AEAD) algorithm.
|
||||
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
#endif
|
||||
|
||||
#include <wolfssl/wolfcrypt/settings.h>
|
||||
|
||||
#if defined(HAVE_CHACHA) && defined(HAVE_POLY1305)
|
||||
|
||||
#include <wolfssl/wolfcrypt/chacha20_poly1305.h>
|
||||
#include <wolfssl/wolfcrypt/error-crypt.h>
|
||||
#include <wolfssl/wolfcrypt/logging.h>
|
||||
|
||||
#ifdef NO_INLINE
|
||||
#include <wolfssl/wolfcrypt/misc.h>
|
||||
#else
|
||||
#define WOLFSSL_MISC_INCLUDED
|
||||
#include <wolfcrypt/src/misc.c>
|
||||
#endif
|
||||
|
||||
#define CHACHA20_POLY1305_AEAD_INITIAL_COUNTER 0
|
||||
int wc_ChaCha20Poly1305_Encrypt(
|
||||
const byte inKey[CHACHA20_POLY1305_AEAD_KEYSIZE],
|
||||
const byte inIV[CHACHA20_POLY1305_AEAD_IV_SIZE],
|
||||
const byte* inAAD, const word32 inAADLen,
|
||||
const byte* inPlaintext, const word32 inPlaintextLen,
|
||||
byte* outCiphertext,
|
||||
byte outAuthTag[CHACHA20_POLY1305_AEAD_AUTHTAG_SIZE])
|
||||
{
|
||||
int ret;
|
||||
ChaChaPoly_Aead aead;
|
||||
|
||||
/* Validate function arguments */
|
||||
if (!inKey || !inIV ||
|
||||
!inPlaintext || !inPlaintextLen ||
|
||||
!outCiphertext ||
|
||||
!outAuthTag)
|
||||
{
|
||||
return BAD_FUNC_ARG;
|
||||
}
|
||||
|
||||
ret = wc_ChaCha20Poly1305_Init(&aead, inKey, inIV,
|
||||
CHACHA20_POLY1305_AEAD_ENCRYPT);
|
||||
if (ret == 0)
|
||||
ret = wc_ChaCha20Poly1305_UpdateAad(&aead, inAAD, inAADLen);
|
||||
if (ret == 0)
|
||||
ret = wc_ChaCha20Poly1305_UpdateData(&aead, inPlaintext, outCiphertext,
|
||||
inPlaintextLen);
|
||||
if (ret == 0)
|
||||
ret = wc_ChaCha20Poly1305_Final(&aead, outAuthTag);
|
||||
return ret;
|
||||
}
|
||||
|
||||
int wc_ChaCha20Poly1305_Decrypt(
|
||||
const byte inKey[CHACHA20_POLY1305_AEAD_KEYSIZE],
|
||||
const byte inIV[CHACHA20_POLY1305_AEAD_IV_SIZE],
|
||||
const byte* inAAD, const word32 inAADLen,
|
||||
const byte* inCiphertext, const word32 inCiphertextLen,
|
||||
const byte inAuthTag[CHACHA20_POLY1305_AEAD_AUTHTAG_SIZE],
|
||||
byte* outPlaintext)
|
||||
{
|
||||
int ret;
|
||||
ChaChaPoly_Aead aead;
|
||||
byte calculatedAuthTag[CHACHA20_POLY1305_AEAD_AUTHTAG_SIZE];
|
||||
|
||||
/* Validate function arguments */
|
||||
if (!inKey || !inIV ||
|
||||
!inCiphertext || !inCiphertextLen ||
|
||||
!inAuthTag ||
|
||||
!outPlaintext)
|
||||
{
|
||||
return BAD_FUNC_ARG;
|
||||
}
|
||||
|
||||
XMEMSET(calculatedAuthTag, 0, sizeof(calculatedAuthTag));
|
||||
|
||||
ret = wc_ChaCha20Poly1305_Init(&aead, inKey, inIV,
|
||||
CHACHA20_POLY1305_AEAD_DECRYPT);
|
||||
if (ret == 0)
|
||||
ret = wc_ChaCha20Poly1305_UpdateAad(&aead, inAAD, inAADLen);
|
||||
if (ret == 0)
|
||||
ret = wc_ChaCha20Poly1305_UpdateData(&aead, inCiphertext, outPlaintext,
|
||||
inCiphertextLen);
|
||||
if (ret == 0)
|
||||
ret = wc_ChaCha20Poly1305_Final(&aead, calculatedAuthTag);
|
||||
if (ret == 0)
|
||||
ret = wc_ChaCha20Poly1305_CheckTag(inAuthTag, calculatedAuthTag);
|
||||
return ret;
|
||||
}
|
||||
|
||||
int wc_ChaCha20Poly1305_CheckTag(
|
||||
const byte authTag[CHACHA20_POLY1305_AEAD_AUTHTAG_SIZE],
|
||||
const byte authTagChk[CHACHA20_POLY1305_AEAD_AUTHTAG_SIZE])
|
||||
{
|
||||
int ret = 0;
|
||||
if (authTag == NULL || authTagChk == NULL) {
|
||||
return BAD_FUNC_ARG;
|
||||
}
|
||||
if (ConstantCompare(authTag, authTagChk,
|
||||
CHACHA20_POLY1305_AEAD_AUTHTAG_SIZE) != 0) {
|
||||
ret = MAC_CMP_FAILED_E;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
int wc_ChaCha20Poly1305_Init(ChaChaPoly_Aead* aead,
|
||||
const byte inKey[CHACHA20_POLY1305_AEAD_KEYSIZE],
|
||||
const byte inIV[CHACHA20_POLY1305_AEAD_IV_SIZE],
|
||||
int isEncrypt)
|
||||
{
|
||||
int ret;
|
||||
byte authKey[CHACHA20_POLY1305_AEAD_KEYSIZE];
|
||||
|
||||
/* check arguments */
|
||||
if (aead == NULL || inKey == NULL || inIV == NULL) {
|
||||
return BAD_FUNC_ARG;
|
||||
}
|
||||
|
||||
/* setup aead context */
|
||||
XMEMSET(aead, 0, sizeof(ChaChaPoly_Aead));
|
||||
XMEMSET(authKey, 0, sizeof(authKey));
|
||||
aead->isEncrypt = (byte)isEncrypt;
|
||||
|
||||
/* Initialize the ChaCha20 context (key and iv) */
|
||||
ret = wc_Chacha_SetKey(&aead->chacha, inKey,
|
||||
CHACHA20_POLY1305_AEAD_KEYSIZE);
|
||||
if (ret == 0) {
|
||||
ret = wc_Chacha_SetIV(&aead->chacha, inIV,
|
||||
CHACHA20_POLY1305_AEAD_INITIAL_COUNTER);
|
||||
}
|
||||
|
||||
/* Create the Poly1305 key */
|
||||
if (ret == 0) {
|
||||
ret = wc_Chacha_Process(&aead->chacha, authKey, authKey,
|
||||
CHACHA20_POLY1305_AEAD_KEYSIZE);
|
||||
}
|
||||
|
||||
/* Initialize Poly1305 context */
|
||||
if (ret == 0) {
|
||||
ret = wc_Poly1305SetKey(&aead->poly, authKey,
|
||||
CHACHA20_POLY1305_AEAD_KEYSIZE);
|
||||
}
|
||||
|
||||
/* advance counter by 1 after creating Poly1305 key */
|
||||
if (ret == 0) {
|
||||
ret = wc_Chacha_SetIV(&aead->chacha, inIV,
|
||||
CHACHA20_POLY1305_AEAD_INITIAL_COUNTER + 1);
|
||||
}
|
||||
|
||||
if (ret == 0) {
|
||||
aead->state = CHACHA20_POLY1305_STATE_READY;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* optional additional authentication data */
|
||||
int wc_ChaCha20Poly1305_UpdateAad(ChaChaPoly_Aead* aead,
|
||||
const byte* inAAD, word32 inAADLen)
|
||||
{
|
||||
int ret = 0;
|
||||
|
||||
if (aead == NULL || (inAAD == NULL && inAADLen > 0)) {
|
||||
return BAD_FUNC_ARG;
|
||||
}
|
||||
if (aead->state != CHACHA20_POLY1305_STATE_READY &&
|
||||
aead->state != CHACHA20_POLY1305_STATE_AAD) {
|
||||
return BAD_STATE_E;
|
||||
}
|
||||
if (inAADLen > CHACHA20_POLY1305_MAX - aead->aadLen)
|
||||
return CHACHA_POLY_OVERFLOW;
|
||||
|
||||
if (inAAD && inAADLen > 0) {
|
||||
ret = wc_Poly1305Update(&aead->poly, inAAD, inAADLen);
|
||||
if (ret == 0) {
|
||||
aead->aadLen += inAADLen;
|
||||
aead->state = CHACHA20_POLY1305_STATE_AAD;
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* inData and outData can be same pointer (inline) */
|
||||
int wc_ChaCha20Poly1305_UpdateData(ChaChaPoly_Aead* aead,
|
||||
const byte* inData, byte* outData, word32 dataLen)
|
||||
{
|
||||
int ret = 0;
|
||||
|
||||
if (aead == NULL || inData == NULL || outData == NULL) {
|
||||
return BAD_FUNC_ARG;
|
||||
}
|
||||
if (aead->state != CHACHA20_POLY1305_STATE_READY &&
|
||||
aead->state != CHACHA20_POLY1305_STATE_AAD &&
|
||||
aead->state != CHACHA20_POLY1305_STATE_DATA) {
|
||||
return BAD_STATE_E;
|
||||
}
|
||||
if (dataLen > CHACHA20_POLY1305_MAX - aead->dataLen)
|
||||
return CHACHA_POLY_OVERFLOW;
|
||||
|
||||
/* Pad the AAD */
|
||||
if (aead->state == CHACHA20_POLY1305_STATE_AAD) {
|
||||
ret = wc_Poly1305_Pad(&aead->poly, aead->aadLen);
|
||||
}
|
||||
|
||||
/* advance state */
|
||||
aead->state = CHACHA20_POLY1305_STATE_DATA;
|
||||
|
||||
/* Perform ChaCha20 encrypt/decrypt and Poly1305 auth calc */
|
||||
if (ret == 0) {
|
||||
if (aead->isEncrypt) {
|
||||
ret = wc_Chacha_Process(&aead->chacha, outData, inData, dataLen);
|
||||
if (ret == 0)
|
||||
ret = wc_Poly1305Update(&aead->poly, outData, dataLen);
|
||||
}
|
||||
else {
|
||||
ret = wc_Poly1305Update(&aead->poly, inData, dataLen);
|
||||
if (ret == 0)
|
||||
ret = wc_Chacha_Process(&aead->chacha, outData, inData, dataLen);
|
||||
}
|
||||
}
|
||||
if (ret == 0) {
|
||||
aead->dataLen += dataLen;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
int wc_ChaCha20Poly1305_Final(ChaChaPoly_Aead* aead,
|
||||
byte outAuthTag[CHACHA20_POLY1305_AEAD_AUTHTAG_SIZE])
|
||||
{
|
||||
int ret = 0;
|
||||
|
||||
if (aead == NULL || outAuthTag == NULL) {
|
||||
return BAD_FUNC_ARG;
|
||||
}
|
||||
if (aead->state != CHACHA20_POLY1305_STATE_AAD &&
|
||||
aead->state != CHACHA20_POLY1305_STATE_DATA) {
|
||||
return BAD_STATE_E;
|
||||
}
|
||||
|
||||
/* Pad the AAD - Make sure it is done */
|
||||
if (aead->state == CHACHA20_POLY1305_STATE_AAD) {
|
||||
ret = wc_Poly1305_Pad(&aead->poly, aead->aadLen);
|
||||
}
|
||||
|
||||
/* Pad the plaintext/ciphertext to 16 bytes */
|
||||
if (ret == 0) {
|
||||
ret = wc_Poly1305_Pad(&aead->poly, aead->dataLen);
|
||||
}
|
||||
|
||||
/* Add the aad length and plaintext/ciphertext length */
|
||||
if (ret == 0) {
|
||||
ret = wc_Poly1305_EncodeSizes(&aead->poly, aead->aadLen,
|
||||
aead->dataLen);
|
||||
}
|
||||
|
||||
/* Finalize the auth tag */
|
||||
if (ret == 0) {
|
||||
ret = wc_Poly1305Final(&aead->poly, outAuthTag);
|
||||
}
|
||||
|
||||
/* reset and cleanup sensitive context */
|
||||
ForceZero(aead, sizeof(ChaChaPoly_Aead));
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
#endif /* HAVE_CHACHA && HAVE_POLY1305 */
|
File diff suppressed because it is too large
Load Diff
@ -1,215 +0,0 @@
|
||||
/* cmac.c
|
||||
*
|
||||
* Copyright (C) 2006-2020 wolfSSL Inc.
|
||||
*
|
||||
* This file is part of wolfSSL.
|
||||
*
|
||||
* wolfSSL is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* wolfSSL is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA
|
||||
*/
|
||||
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
#endif
|
||||
|
||||
#include <wolfssl/wolfcrypt/settings.h>
|
||||
|
||||
#if defined(WOLFSSL_CMAC) && !defined(NO_AES) && defined(WOLFSSL_AES_DIRECT)
|
||||
|
||||
#if defined(HAVE_FIPS) && \
|
||||
defined(HAVE_FIPS_VERSION) && (HAVE_FIPS_VERSION >= 2)
|
||||
|
||||
/* set NO_WRAPPERS before headers, use direct internal f()s not wrappers */
|
||||
#define FIPS_NO_WRAPPERS
|
||||
|
||||
#ifdef USE_WINDOWS_API
|
||||
#pragma code_seg(".fipsA$n")
|
||||
#pragma const_seg(".fipsB$n")
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef NO_INLINE
|
||||
#include <wolfssl/wolfcrypt/misc.h>
|
||||
#else
|
||||
#define WOLFSSL_MISC_INCLUDED
|
||||
#include <wolfcrypt/src/misc.c>
|
||||
#endif
|
||||
|
||||
#include <wolfssl/wolfcrypt/error-crypt.h>
|
||||
#include <wolfssl/wolfcrypt/aes.h>
|
||||
#include <wolfssl/wolfcrypt/cmac.h>
|
||||
|
||||
|
||||
static void ShiftAndXorRb(byte* out, byte* in)
|
||||
{
|
||||
int i, j, xorRb;
|
||||
int mask = 0, last = 0;
|
||||
byte Rb = 0x87;
|
||||
|
||||
xorRb = (in[0] & 0x80) != 0;
|
||||
|
||||
for (i = 1, j = AES_BLOCK_SIZE - 1; i <= AES_BLOCK_SIZE; i++, j--) {
|
||||
last = (in[j] & 0x80) ? 1 : 0;
|
||||
out[j] = (byte)((in[j] << 1) | mask);
|
||||
mask = last;
|
||||
if (xorRb) {
|
||||
out[j] ^= Rb;
|
||||
Rb = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int wc_InitCmac(Cmac* cmac, const byte* key, word32 keySz,
|
||||
int type, void* unused)
|
||||
{
|
||||
int ret;
|
||||
|
||||
(void)unused;
|
||||
|
||||
if (cmac == NULL || key == NULL || keySz == 0 || type != WC_CMAC_AES)
|
||||
return BAD_FUNC_ARG;
|
||||
|
||||
XMEMSET(cmac, 0, sizeof(Cmac));
|
||||
ret = wc_AesSetKey(&cmac->aes, key, keySz, NULL, AES_ENCRYPTION);
|
||||
if (ret == 0) {
|
||||
byte l[AES_BLOCK_SIZE];
|
||||
|
||||
XMEMSET(l, 0, AES_BLOCK_SIZE);
|
||||
wc_AesEncryptDirect(&cmac->aes, l, l);
|
||||
ShiftAndXorRb(cmac->k1, l);
|
||||
ShiftAndXorRb(cmac->k2, cmac->k1);
|
||||
ForceZero(l, AES_BLOCK_SIZE);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
int wc_CmacUpdate(Cmac* cmac, const byte* in, word32 inSz)
|
||||
{
|
||||
if ((cmac == NULL) || (in == NULL && inSz != 0))
|
||||
return BAD_FUNC_ARG;
|
||||
|
||||
while (inSz != 0) {
|
||||
word32 add = min(inSz, AES_BLOCK_SIZE - cmac->bufferSz);
|
||||
XMEMCPY(&cmac->buffer[cmac->bufferSz], in, add);
|
||||
|
||||
cmac->bufferSz += add;
|
||||
in += add;
|
||||
inSz -= add;
|
||||
|
||||
if (cmac->bufferSz == AES_BLOCK_SIZE && inSz != 0) {
|
||||
if (cmac->totalSz != 0)
|
||||
xorbuf(cmac->buffer, cmac->digest, AES_BLOCK_SIZE);
|
||||
wc_AesEncryptDirect(&cmac->aes,
|
||||
cmac->digest,
|
||||
cmac->buffer);
|
||||
cmac->totalSz += AES_BLOCK_SIZE;
|
||||
cmac->bufferSz = 0;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int wc_CmacFinal(Cmac* cmac, byte* out, word32* outSz)
|
||||
{
|
||||
const byte* subKey;
|
||||
|
||||
if (cmac == NULL || out == NULL || outSz == NULL)
|
||||
return BAD_FUNC_ARG;
|
||||
|
||||
if (*outSz < WC_CMAC_TAG_MIN_SZ || *outSz > WC_CMAC_TAG_MAX_SZ)
|
||||
return BUFFER_E;
|
||||
|
||||
if (cmac->bufferSz == AES_BLOCK_SIZE) {
|
||||
subKey = cmac->k1;
|
||||
}
|
||||
else {
|
||||
word32 remainder = AES_BLOCK_SIZE - cmac->bufferSz;
|
||||
|
||||
if (remainder == 0)
|
||||
remainder = AES_BLOCK_SIZE;
|
||||
|
||||
if (remainder > 1)
|
||||
XMEMSET(cmac->buffer + AES_BLOCK_SIZE - remainder, 0, remainder);
|
||||
cmac->buffer[AES_BLOCK_SIZE - remainder] = 0x80;
|
||||
subKey = cmac->k2;
|
||||
}
|
||||
xorbuf(cmac->buffer, cmac->digest, AES_BLOCK_SIZE);
|
||||
xorbuf(cmac->buffer, subKey, AES_BLOCK_SIZE);
|
||||
wc_AesEncryptDirect(&cmac->aes, cmac->digest, cmac->buffer);
|
||||
|
||||
XMEMCPY(out, cmac->digest, *outSz);
|
||||
|
||||
ForceZero(cmac, sizeof(Cmac));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int wc_AesCmacGenerate(byte* out, word32* outSz,
|
||||
const byte* in, word32 inSz,
|
||||
const byte* key, word32 keySz)
|
||||
{
|
||||
Cmac cmac;
|
||||
int ret;
|
||||
|
||||
if (out == NULL || (in == NULL && inSz > 0) || key == NULL || keySz == 0)
|
||||
return BAD_FUNC_ARG;
|
||||
|
||||
ret = wc_InitCmac(&cmac, key, keySz, WC_CMAC_AES, NULL);
|
||||
if (ret != 0)
|
||||
return ret;
|
||||
|
||||
ret = wc_CmacUpdate(&cmac, in, inSz);
|
||||
if (ret != 0)
|
||||
return ret;
|
||||
|
||||
ret = wc_CmacFinal(&cmac, out, outSz);
|
||||
if (ret != 0)
|
||||
return ret;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int wc_AesCmacVerify(const byte* check, word32 checkSz,
|
||||
const byte* in, word32 inSz,
|
||||
const byte* key, word32 keySz)
|
||||
{
|
||||
byte a[AES_BLOCK_SIZE];
|
||||
word32 aSz = sizeof(a);
|
||||
int result;
|
||||
int compareRet;
|
||||
|
||||
if (check == NULL || checkSz == 0 || (in == NULL && inSz != 0) ||
|
||||
key == NULL || keySz == 0)
|
||||
|
||||
return BAD_FUNC_ARG;
|
||||
|
||||
XMEMSET(a, 0, aSz);
|
||||
result = wc_AesCmacGenerate(a, &aSz, in, inSz, key, keySz);
|
||||
compareRet = ConstantCompare(check, a, min(checkSz, aSz));
|
||||
|
||||
if (result == 0)
|
||||
result = compareRet ? 1 : 0;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
#endif /* WOLFSSL_CMAC && NO_AES && WOLFSSL_AES_DIRECT */
|
@ -1,518 +0,0 @@
|
||||
/* coding.c
|
||||
*
|
||||
* Copyright (C) 2006-2020 wolfSSL Inc.
|
||||
*
|
||||
* This file is part of wolfSSL.
|
||||
*
|
||||
* wolfSSL is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* wolfSSL is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA
|
||||
*/
|
||||
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
#endif
|
||||
|
||||
#include <wolfssl/wolfcrypt/settings.h>
|
||||
|
||||
#ifndef NO_CODING
|
||||
|
||||
#include <wolfssl/wolfcrypt/coding.h>
|
||||
#include <wolfssl/wolfcrypt/error-crypt.h>
|
||||
#include <wolfssl/wolfcrypt/logging.h>
|
||||
#ifndef NO_ASN
|
||||
#include <wolfssl/wolfcrypt/asn.h> /* For PEM_LINE_SZ */
|
||||
#endif
|
||||
|
||||
enum {
|
||||
BAD = 0xFF, /* invalid encoding */
|
||||
PAD = '=',
|
||||
BASE64_MIN = 0x2B,
|
||||
BASE16_MIN = 0x30,
|
||||
};
|
||||
|
||||
|
||||
#ifndef BASE64_LINE_SZ
|
||||
#ifdef NO_ASN
|
||||
#define BASE64_LINE_SZ 64
|
||||
#else
|
||||
#define BASE64_LINE_SZ PEM_LINE_SZ
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef WOLFSSL_BASE64_DECODE
|
||||
|
||||
static
|
||||
const byte base64Decode[] = { 62, BAD, BAD, BAD, 63, /* + starts at 0x2B */
|
||||
52, 53, 54, 55, 56, 57, 58, 59, 60, 61,
|
||||
BAD, BAD, BAD, BAD, BAD, BAD, BAD,
|
||||
0, 1, 2, 3, 4, 5, 6, 7, 8, 9,
|
||||
10, 11, 12, 13, 14, 15, 16, 17, 18, 19,
|
||||
20, 21, 22, 23, 24, 25,
|
||||
BAD, BAD, BAD, BAD, BAD, BAD,
|
||||
26, 27, 28, 29, 30, 31, 32, 33, 34, 35,
|
||||
36, 37, 38, 39, 40, 41, 42, 43, 44, 45,
|
||||
46, 47, 48, 49, 50, 51
|
||||
};
|
||||
|
||||
static WC_INLINE int Base64_SkipNewline(const byte* in, word32 *inLen, word32 *outJ)
|
||||
{
|
||||
word32 len = *inLen;
|
||||
word32 j = *outJ;
|
||||
if (len && (in[j] == ' ' || in[j] == '\r' || in[j] == '\n')) {
|
||||
byte endLine = in[j++];
|
||||
len--;
|
||||
while (len && endLine == ' ') { /* allow trailing whitespace */
|
||||
endLine = in[j++];
|
||||
len--;
|
||||
}
|
||||
if (endLine == '\r') {
|
||||
if (len) {
|
||||
endLine = in[j++];
|
||||
len--;
|
||||
}
|
||||
}
|
||||
if (endLine != '\n') {
|
||||
WOLFSSL_MSG("Bad end of line in Base64 Decode");
|
||||
return ASN_INPUT_E;
|
||||
}
|
||||
}
|
||||
if (!len) {
|
||||
return BUFFER_E;
|
||||
}
|
||||
*inLen = len;
|
||||
*outJ = j;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int Base64_Decode(const byte* in, word32 inLen, byte* out, word32* outLen)
|
||||
{
|
||||
word32 i = 0;
|
||||
word32 j = 0;
|
||||
word32 plainSz = inLen - ((inLen + (BASE64_LINE_SZ - 1)) / BASE64_LINE_SZ );
|
||||
int ret;
|
||||
const byte maxIdx = (byte)sizeof(base64Decode) + BASE64_MIN - 1;
|
||||
|
||||
plainSz = (plainSz * 3 + 3) / 4;
|
||||
if (plainSz > *outLen) return BAD_FUNC_ARG;
|
||||
|
||||
while (inLen > 3) {
|
||||
int pad3 = 0;
|
||||
int pad4 = 0;
|
||||
|
||||
byte b1, b2, b3;
|
||||
byte e1, e2, e3, e4;
|
||||
if ((ret = Base64_SkipNewline(in, &inLen, &j)) != 0) {
|
||||
if (ret == BUFFER_E) {
|
||||
/* Running out of buffer here is not an error */
|
||||
break;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
e1 = in[j++];
|
||||
if (e1 == '\0') {
|
||||
break;
|
||||
}
|
||||
inLen--;
|
||||
if ((ret = Base64_SkipNewline(in, &inLen, &j)) != 0) {
|
||||
return ret;
|
||||
}
|
||||
e2 = in[j++];
|
||||
inLen--;
|
||||
if ((ret = Base64_SkipNewline(in, &inLen, &j)) != 0) {
|
||||
return ret;
|
||||
}
|
||||
e3 = in[j++];
|
||||
inLen--;
|
||||
if ((ret = Base64_SkipNewline(in, &inLen, &j)) != 0) {
|
||||
return ret;
|
||||
}
|
||||
e4 = in[j++];
|
||||
inLen--;
|
||||
|
||||
if (e3 == PAD)
|
||||
pad3 = 1;
|
||||
if (e4 == PAD)
|
||||
pad4 = 1;
|
||||
|
||||
if (e1 < BASE64_MIN || e2 < BASE64_MIN || e3 < BASE64_MIN || e4 < BASE64_MIN) {
|
||||
WOLFSSL_MSG("Bad Base64 Decode data, too small");
|
||||
return ASN_INPUT_E;
|
||||
}
|
||||
|
||||
if (e1 > maxIdx || e2 > maxIdx || e3 > maxIdx || e4 > maxIdx) {
|
||||
WOLFSSL_MSG("Bad Base64 Decode data, too big");
|
||||
return ASN_INPUT_E;
|
||||
}
|
||||
|
||||
if (i + 1 + !pad3 + !pad4 > *outLen) {
|
||||
WOLFSSL_MSG("Bad Base64 Decode out buffer, too small");
|
||||
return BAD_FUNC_ARG;
|
||||
}
|
||||
|
||||
e1 = base64Decode[e1 - BASE64_MIN];
|
||||
e2 = base64Decode[e2 - BASE64_MIN];
|
||||
e3 = (e3 == PAD) ? 0 : base64Decode[e3 - BASE64_MIN];
|
||||
e4 = (e4 == PAD) ? 0 : base64Decode[e4 - BASE64_MIN];
|
||||
|
||||
b1 = (byte)((e1 << 2) | (e2 >> 4));
|
||||
b2 = (byte)(((e2 & 0xF) << 4) | (e3 >> 2));
|
||||
b3 = (byte)(((e3 & 0x3) << 6) | e4);
|
||||
|
||||
out[i++] = b1;
|
||||
if (!pad3)
|
||||
out[i++] = b2;
|
||||
if (!pad4)
|
||||
out[i++] = b3;
|
||||
else
|
||||
break;
|
||||
}
|
||||
/* If the output buffer has a room for an extra byte, add a null terminator */
|
||||
if (out && *outLen > i)
|
||||
out[i]= '\0';
|
||||
|
||||
*outLen = i;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif /* WOLFSSL_BASE64_DECODE */
|
||||
|
||||
#if defined(WOLFSSL_BASE64_ENCODE)
|
||||
|
||||
static
|
||||
const byte base64Encode[] = { 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J',
|
||||
'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T',
|
||||
'U', 'V', 'W', 'X', 'Y', 'Z',
|
||||
'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j',
|
||||
'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't',
|
||||
'u', 'v', 'w', 'x', 'y', 'z',
|
||||
'0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
|
||||
'+', '/'
|
||||
};
|
||||
|
||||
|
||||
/* make sure *i (idx) won't exceed max, store and possibly escape to out,
|
||||
* raw means use e w/o decode, 0 on success */
|
||||
static int CEscape(int escaped, byte e, byte* out, word32* i, word32 max,
|
||||
int raw, int getSzOnly)
|
||||
{
|
||||
int doEscape = 0;
|
||||
word32 needed = 1;
|
||||
word32 idx = *i;
|
||||
|
||||
byte basic;
|
||||
byte plus = 0;
|
||||
byte equals = 0;
|
||||
byte newline = 0;
|
||||
|
||||
if (raw)
|
||||
basic = e;
|
||||
else
|
||||
basic = base64Encode[e];
|
||||
|
||||
/* check whether to escape. Only escape for EncodeEsc */
|
||||
if (escaped == WC_ESC_NL_ENC) {
|
||||
switch ((char)basic) {
|
||||
case '+' :
|
||||
plus = 1;
|
||||
doEscape = 1;
|
||||
needed += 2;
|
||||
break;
|
||||
case '=' :
|
||||
equals = 1;
|
||||
doEscape = 1;
|
||||
needed += 2;
|
||||
break;
|
||||
case '\n' :
|
||||
newline = 1;
|
||||
doEscape = 1;
|
||||
needed += 2;
|
||||
break;
|
||||
default:
|
||||
/* do nothing */
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* check size */
|
||||
if ( (idx+needed) > max && !getSzOnly) {
|
||||
WOLFSSL_MSG("Escape buffer max too small");
|
||||
return BUFFER_E;
|
||||
}
|
||||
|
||||
/* store it */
|
||||
if (doEscape == 0) {
|
||||
if(getSzOnly)
|
||||
idx++;
|
||||
else
|
||||
out[idx++] = basic;
|
||||
}
|
||||
else {
|
||||
if(getSzOnly)
|
||||
idx+=3;
|
||||
else {
|
||||
out[idx++] = '%'; /* start escape */
|
||||
|
||||
if (plus) {
|
||||
out[idx++] = '2';
|
||||
out[idx++] = 'B';
|
||||
}
|
||||
else if (equals) {
|
||||
out[idx++] = '3';
|
||||
out[idx++] = 'D';
|
||||
}
|
||||
else if (newline) {
|
||||
out[idx++] = '0';
|
||||
out[idx++] = 'A';
|
||||
}
|
||||
}
|
||||
}
|
||||
*i = idx;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/* internal worker, handles both escaped and normal line endings.
|
||||
If out buffer is NULL, will return sz needed in outLen */
|
||||
static int DoBase64_Encode(const byte* in, word32 inLen, byte* out,
|
||||
word32* outLen, int escaped)
|
||||
{
|
||||
int ret = 0;
|
||||
word32 i = 0,
|
||||
j = 0,
|
||||
n = 0; /* new line counter */
|
||||
|
||||
int getSzOnly = (out == NULL);
|
||||
|
||||
word32 outSz = (inLen + 3 - 1) / 3 * 4;
|
||||
word32 addSz = (outSz + BASE64_LINE_SZ - 1) / BASE64_LINE_SZ; /* new lines */
|
||||
|
||||
if (escaped == WC_ESC_NL_ENC)
|
||||
addSz *= 3; /* instead of just \n, we're doing %0A triplet */
|
||||
else if (escaped == WC_NO_NL_ENC)
|
||||
addSz = 0; /* encode without \n */
|
||||
|
||||
outSz += addSz;
|
||||
|
||||
/* if escaped we can't predetermine size for one pass encoding, but
|
||||
* make sure we have enough if no escapes are in input
|
||||
* Also need to ensure outLen valid before dereference */
|
||||
if (!outLen || (outSz > *outLen && !getSzOnly)) return BAD_FUNC_ARG;
|
||||
|
||||
while (inLen > 2) {
|
||||
byte b1 = in[j++];
|
||||
byte b2 = in[j++];
|
||||
byte b3 = in[j++];
|
||||
|
||||
/* encoded idx */
|
||||
byte e1 = b1 >> 2;
|
||||
byte e2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));
|
||||
byte e3 = (byte)(((b2 & 0xF) << 2) | (b3 >> 6));
|
||||
byte e4 = b3 & 0x3F;
|
||||
|
||||
/* store */
|
||||
ret = CEscape(escaped, e1, out, &i, *outLen, 0, getSzOnly);
|
||||
if (ret != 0) break;
|
||||
ret = CEscape(escaped, e2, out, &i, *outLen, 0, getSzOnly);
|
||||
if (ret != 0) break;
|
||||
ret = CEscape(escaped, e3, out, &i, *outLen, 0, getSzOnly);
|
||||
if (ret != 0) break;
|
||||
ret = CEscape(escaped, e4, out, &i, *outLen, 0, getSzOnly);
|
||||
if (ret != 0) break;
|
||||
|
||||
inLen -= 3;
|
||||
|
||||
/* Insert newline after BASE64_LINE_SZ, unless no \n requested */
|
||||
if (escaped != WC_NO_NL_ENC && (++n % (BASE64_LINE_SZ/4)) == 0 && inLen) {
|
||||
ret = CEscape(escaped, '\n', out, &i, *outLen, 1, getSzOnly);
|
||||
if (ret != 0) break;
|
||||
}
|
||||
}
|
||||
|
||||
/* last integral */
|
||||
if (inLen && ret == 0) {
|
||||
int twoBytes = (inLen == 2);
|
||||
|
||||
byte b1 = in[j++];
|
||||
byte b2 = (twoBytes) ? in[j++] : 0;
|
||||
|
||||
byte e1 = b1 >> 2;
|
||||
byte e2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));
|
||||
byte e3 = (byte)((b2 & 0xF) << 2);
|
||||
|
||||
ret = CEscape(escaped, e1, out, &i, *outLen, 0, getSzOnly);
|
||||
if (ret == 0)
|
||||
ret = CEscape(escaped, e2, out, &i, *outLen, 0, getSzOnly);
|
||||
if (ret == 0) {
|
||||
/* third */
|
||||
if (twoBytes)
|
||||
ret = CEscape(escaped, e3, out, &i, *outLen, 0, getSzOnly);
|
||||
else
|
||||
ret = CEscape(escaped, '=', out, &i, *outLen, 1, getSzOnly);
|
||||
}
|
||||
/* fourth always pad */
|
||||
if (ret == 0)
|
||||
ret = CEscape(escaped, '=', out, &i, *outLen, 1, getSzOnly);
|
||||
}
|
||||
|
||||
if (ret == 0 && escaped != WC_NO_NL_ENC)
|
||||
ret = CEscape(escaped, '\n', out, &i, *outLen, 1, getSzOnly);
|
||||
|
||||
if (i != outSz && escaped != 1 && ret == 0)
|
||||
return ASN_INPUT_E;
|
||||
/* If the output buffer has a room for an extra byte, add a null terminator */
|
||||
if (out && *outLen > i)
|
||||
out[i]= '\0';
|
||||
|
||||
*outLen = i;
|
||||
|
||||
if (ret == 0)
|
||||
return getSzOnly ? LENGTH_ONLY_E : 0;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
/* Base64 Encode, PEM style, with \n line endings */
|
||||
int Base64_Encode(const byte* in, word32 inLen, byte* out, word32* outLen)
|
||||
{
|
||||
return DoBase64_Encode(in, inLen, out, outLen, WC_STD_ENC);
|
||||
}
|
||||
|
||||
|
||||
/* Base64 Encode, with %0A escaped line endings instead of \n */
|
||||
int Base64_EncodeEsc(const byte* in, word32 inLen, byte* out, word32* outLen)
|
||||
{
|
||||
return DoBase64_Encode(in, inLen, out, outLen, WC_ESC_NL_ENC);
|
||||
}
|
||||
|
||||
int Base64_Encode_NoNl(const byte* in, word32 inLen, byte* out, word32* outLen)
|
||||
{
|
||||
return DoBase64_Encode(in, inLen, out, outLen, WC_NO_NL_ENC);
|
||||
}
|
||||
|
||||
#endif /* WOLFSSL_BASE64_ENCODE */
|
||||
|
||||
|
||||
#ifdef WOLFSSL_BASE16
|
||||
|
||||
static
|
||||
const byte hexDecode[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,
|
||||
BAD, BAD, BAD, BAD, BAD, BAD, BAD,
|
||||
10, 11, 12, 13, 14, 15, /* upper case A-F */
|
||||
BAD, BAD, BAD, BAD, BAD, BAD, BAD, BAD,
|
||||
BAD, BAD, BAD, BAD, BAD, BAD, BAD, BAD,
|
||||
BAD, BAD, BAD, BAD, BAD, BAD, BAD, BAD,
|
||||
BAD, BAD, /* G - ` */
|
||||
10, 11, 12, 13, 14, 15 /* lower case a-f */
|
||||
}; /* A starts at 0x41 not 0x3A */
|
||||
|
||||
int Base16_Decode(const byte* in, word32 inLen, byte* out, word32* outLen)
|
||||
{
|
||||
word32 inIdx = 0;
|
||||
word32 outIdx = 0;
|
||||
|
||||
if (in == NULL || out == NULL || outLen == NULL)
|
||||
return BAD_FUNC_ARG;
|
||||
|
||||
if (inLen == 1 && *outLen && in) {
|
||||
byte b = in[inIdx++] - BASE16_MIN; /* 0 starts at 0x30 */
|
||||
|
||||
/* sanity check */
|
||||
if (b >= sizeof(hexDecode)/sizeof(hexDecode[0]))
|
||||
return ASN_INPUT_E;
|
||||
|
||||
b = hexDecode[b];
|
||||
|
||||
if (b == BAD)
|
||||
return ASN_INPUT_E;
|
||||
|
||||
out[outIdx++] = b;
|
||||
|
||||
*outLen = outIdx;
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (inLen % 2)
|
||||
return BAD_FUNC_ARG;
|
||||
|
||||
if (*outLen < (inLen / 2))
|
||||
return BAD_FUNC_ARG;
|
||||
|
||||
while (inLen) {
|
||||
byte b = in[inIdx++] - BASE16_MIN; /* 0 starts at 0x30 */
|
||||
byte b2 = in[inIdx++] - BASE16_MIN;
|
||||
|
||||
/* sanity checks */
|
||||
if (b >= sizeof(hexDecode)/sizeof(hexDecode[0]))
|
||||
return ASN_INPUT_E;
|
||||
if (b2 >= sizeof(hexDecode)/sizeof(hexDecode[0]))
|
||||
return ASN_INPUT_E;
|
||||
|
||||
b = hexDecode[b];
|
||||
b2 = hexDecode[b2];
|
||||
|
||||
if (b == BAD || b2 == BAD)
|
||||
return ASN_INPUT_E;
|
||||
|
||||
out[outIdx++] = (byte)((b << 4) | b2);
|
||||
inLen -= 2;
|
||||
}
|
||||
|
||||
*outLen = outIdx;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int Base16_Encode(const byte* in, word32 inLen, byte* out, word32* outLen)
|
||||
{
|
||||
word32 outIdx = 0;
|
||||
word32 i;
|
||||
byte hb, lb;
|
||||
|
||||
if (in == NULL || out == NULL || outLen == NULL)
|
||||
return BAD_FUNC_ARG;
|
||||
|
||||
if (*outLen < (2 * inLen + 1))
|
||||
return BAD_FUNC_ARG;
|
||||
|
||||
for (i = 0; i < inLen; i++) {
|
||||
hb = in[i] >> 4;
|
||||
lb = in[i] & 0x0f;
|
||||
|
||||
/* ASCII value */
|
||||
hb += '0';
|
||||
if (hb > '9')
|
||||
hb += 7;
|
||||
|
||||
/* ASCII value */
|
||||
lb += '0';
|
||||
if (lb>'9')
|
||||
lb += 7;
|
||||
|
||||
out[outIdx++] = hb;
|
||||
out[outIdx++] = lb;
|
||||
}
|
||||
|
||||
/* force 0 at this end */
|
||||
out[outIdx++] = 0;
|
||||
|
||||
*outLen = outIdx;
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif /* WOLFSSL_BASE16 */
|
||||
|
||||
#endif /* !NO_CODING */
|
@ -1,198 +0,0 @@
|
||||
/* compress.c
|
||||
*
|
||||
* Copyright (C) 2006-2020 wolfSSL Inc.
|
||||
*
|
||||
* This file is part of wolfSSL.
|
||||
*
|
||||
* wolfSSL is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* wolfSSL is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA
|
||||
*/
|
||||
|
||||
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
#endif
|
||||
|
||||
#include <wolfssl/wolfcrypt/settings.h>
|
||||
|
||||
#ifdef HAVE_LIBZ
|
||||
|
||||
|
||||
#include <wolfssl/wolfcrypt/compress.h>
|
||||
#include <wolfssl/wolfcrypt/error-crypt.h>
|
||||
#include <wolfssl/wolfcrypt/logging.h>
|
||||
#ifdef NO_INLINE
|
||||
#include <wolfssl/wolfcrypt/misc.h>
|
||||
#else
|
||||
#define WOLFSSL_MISC_INCLUDED
|
||||
#include <wolfcrypt/src/misc.c>
|
||||
#endif
|
||||
|
||||
#include <zlib.h>
|
||||
|
||||
|
||||
/* alloc user allocs to work with zlib */
|
||||
static void* myAlloc(void* opaque, unsigned int item, unsigned int size)
|
||||
{
|
||||
(void)opaque;
|
||||
return XMALLOC(item * size, opaque, DYNAMIC_TYPE_LIBZ);
|
||||
}
|
||||
|
||||
|
||||
static void myFree(void* opaque, void* memory)
|
||||
{
|
||||
(void)opaque;
|
||||
XFREE(memory, opaque, DYNAMIC_TYPE_LIBZ);
|
||||
}
|
||||
|
||||
|
||||
#ifdef HAVE_MCAPI
|
||||
#define DEFLATE_DEFAULT_WINDOWBITS 11
|
||||
#define DEFLATE_DEFAULT_MEMLEVEL 1
|
||||
#else
|
||||
#define DEFLATE_DEFAULT_WINDOWBITS 15
|
||||
#define DEFLATE_DEFAULT_MEMLEVEL 8
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
* out - pointer to destination buffer
|
||||
* outSz - size of destination buffer
|
||||
* in - pointer to source buffer to compress
|
||||
* inSz - size of source to compress
|
||||
* flags - flags to control how compress operates
|
||||
*
|
||||
* return:
|
||||
* negative - error code
|
||||
* positive - bytes stored in out buffer
|
||||
*
|
||||
* Note, the output buffer still needs to be larger than the input buffer.
|
||||
* The right chunk of data won't compress at all, and the lookup table will
|
||||
* add to the size of the output. The libz code says the compressed
|
||||
* buffer should be srcSz + 0.1% + 12.
|
||||
*/
|
||||
int wc_Compress_ex(byte* out, word32 outSz, const byte* in, word32 inSz,
|
||||
word32 flags, word32 windowBits)
|
||||
{
|
||||
z_stream stream;
|
||||
int result = 0;
|
||||
|
||||
stream.next_in = (Bytef*)in;
|
||||
stream.avail_in = (uInt)inSz;
|
||||
#ifdef MAXSEG_64K
|
||||
/* Check for source > 64K on 16-bit machine: */
|
||||
if ((uLong)stream.avail_in != inSz) return COMPRESS_INIT_E;
|
||||
#endif
|
||||
stream.next_out = out;
|
||||
stream.avail_out = (uInt)outSz;
|
||||
if ((uLong)stream.avail_out != outSz) return COMPRESS_INIT_E;
|
||||
|
||||
stream.zalloc = (alloc_func)myAlloc;
|
||||
stream.zfree = (free_func)myFree;
|
||||
stream.opaque = (voidpf)0;
|
||||
|
||||
if (deflateInit2(&stream, Z_DEFAULT_COMPRESSION, Z_DEFLATED,
|
||||
DEFLATE_DEFAULT_WINDOWBITS | windowBits,
|
||||
DEFLATE_DEFAULT_MEMLEVEL,
|
||||
flags ? Z_FIXED : Z_DEFAULT_STRATEGY) != Z_OK)
|
||||
return COMPRESS_INIT_E;
|
||||
|
||||
if (deflate(&stream, Z_FINISH) != Z_STREAM_END) {
|
||||
deflateEnd(&stream);
|
||||
return COMPRESS_E;
|
||||
}
|
||||
|
||||
result = (int)stream.total_out;
|
||||
|
||||
if (deflateEnd(&stream) != Z_OK)
|
||||
result = COMPRESS_E;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
int wc_Compress(byte* out, word32 outSz, const byte* in, word32 inSz, word32 flags)
|
||||
{
|
||||
return wc_Compress_ex(out, outSz, in, inSz, flags, 0);
|
||||
}
|
||||
|
||||
|
||||
/* windowBits:
|
||||
* deflateInit() and inflateInit(), as well as deflateInit2() and inflateInit2()
|
||||
with windowBits in 0..15 all process zlib-wrapped deflate data.
|
||||
(See RFC 1950 and RFC 1951.)
|
||||
* deflateInit2() and inflateInit2() with negative windowBits in -1..-15 process
|
||||
raw deflate data with no header or trailer.
|
||||
* deflateInit2() and inflateInit2() with windowBits in 16..31, i.e. 16
|
||||
added to 0..15, process gzip-wrapped deflate data (RFC 1952).
|
||||
* inflateInit2() with windowBits in 32..47 (32 added to 0..15) will
|
||||
automatically detect either a gzip or zlib header (but not raw deflate
|
||||
data), and decompress accordingly.
|
||||
*/
|
||||
int wc_DeCompress_ex(byte* out, word32 outSz, const byte* in, word32 inSz,
|
||||
int windowBits)
|
||||
/*
|
||||
* out - pointer to destination buffer
|
||||
* outSz - size of destination buffer
|
||||
* in - pointer to source buffer to compress
|
||||
* inSz - size of source to compress
|
||||
* windowBits - flags to control how decompress operates
|
||||
*
|
||||
* return:
|
||||
* negative - error code
|
||||
* positive - bytes stored in out buffer
|
||||
*/
|
||||
{
|
||||
z_stream stream;
|
||||
int result = 0;
|
||||
|
||||
stream.next_in = (Bytef*)in;
|
||||
stream.avail_in = (uInt)inSz;
|
||||
/* Check for source > 64K on 16-bit machine: */
|
||||
if ((uLong)stream.avail_in != inSz) return DECOMPRESS_INIT_E;
|
||||
|
||||
stream.next_out = out;
|
||||
stream.avail_out = (uInt)outSz;
|
||||
if ((uLong)stream.avail_out != outSz) return DECOMPRESS_INIT_E;
|
||||
|
||||
stream.zalloc = (alloc_func)myAlloc;
|
||||
stream.zfree = (free_func)myFree;
|
||||
stream.opaque = (voidpf)0;
|
||||
|
||||
if (inflateInit2(&stream, DEFLATE_DEFAULT_WINDOWBITS | windowBits) != Z_OK)
|
||||
return DECOMPRESS_INIT_E;
|
||||
|
||||
result = inflate(&stream, Z_FINISH);
|
||||
if (result != Z_STREAM_END) {
|
||||
inflateEnd(&stream);
|
||||
return DECOMPRESS_E;
|
||||
}
|
||||
|
||||
result = (int)stream.total_out;
|
||||
|
||||
if (inflateEnd(&stream) != Z_OK)
|
||||
result = DECOMPRESS_E;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
int wc_DeCompress(byte* out, word32 outSz, const byte* in, word32 inSz)
|
||||
{
|
||||
return wc_DeCompress_ex(out, outSz, in, inSz, 0);
|
||||
}
|
||||
|
||||
|
||||
#endif /* HAVE_LIBZ */
|
||||
|
@ -1,111 +0,0 @@
|
||||
/* cpuid.c
|
||||
*
|
||||
* Copyright (C) 2006-2020 wolfSSL Inc.
|
||||
*
|
||||
* This file is part of wolfSSL.
|
||||
*
|
||||
* wolfSSL is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* wolfSSL is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA
|
||||
*/
|
||||
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
#endif
|
||||
|
||||
#include <wolfssl/wolfcrypt/settings.h>
|
||||
|
||||
#include <wolfssl/wolfcrypt/cpuid.h>
|
||||
|
||||
#if (defined(WOLFSSL_X86_64_BUILD) || defined(USE_INTEL_SPEEDUP) || \
|
||||
defined(WOLFSSL_AESNI)) && !defined(WOLFSSL_NO_ASM)
|
||||
/* Each platform needs to query info type 1 from cpuid to see if aesni is
|
||||
* supported. Also, let's setup a macro for proper linkage w/o ABI conflicts
|
||||
*/
|
||||
|
||||
#ifndef _MSC_VER
|
||||
#define cpuid(reg, leaf, sub)\
|
||||
__asm__ __volatile__ ("cpuid":\
|
||||
"=a" (reg[0]), "=b" (reg[1]), "=c" (reg[2]), "=d" (reg[3]) :\
|
||||
"a" (leaf), "c"(sub));
|
||||
|
||||
#define XASM_LINK(f) asm(f)
|
||||
#else
|
||||
#include <intrin.h>
|
||||
|
||||
#define cpuid(a,b,c) __cpuidex((int*)a,b,c)
|
||||
|
||||
#define XASM_LINK(f)
|
||||
#endif /* _MSC_VER */
|
||||
|
||||
#define EAX 0
|
||||
#define EBX 1
|
||||
#define ECX 2
|
||||
#define EDX 3
|
||||
|
||||
static word32 cpuid_check = 0;
|
||||
static word32 cpuid_flags = 0;
|
||||
|
||||
static word32 cpuid_flag(word32 leaf, word32 sub, word32 num, word32 bit)
|
||||
{
|
||||
int got_intel_cpu = 0;
|
||||
int got_amd_cpu = 0;
|
||||
unsigned int reg[5];
|
||||
reg[4] = '\0';
|
||||
cpuid(reg, 0, 0);
|
||||
|
||||
/* check for Intel cpu */
|
||||
if (XMEMCMP((char *)&(reg[EBX]), "Genu", 4) == 0 &&
|
||||
XMEMCMP((char *)&(reg[EDX]), "ineI", 4) == 0 &&
|
||||
XMEMCMP((char *)&(reg[ECX]), "ntel", 4) == 0) {
|
||||
got_intel_cpu = 1;
|
||||
}
|
||||
|
||||
/* check for AMD cpu */
|
||||
if (XMEMCMP((char *)&(reg[EBX]), "Auth", 4) == 0 &&
|
||||
XMEMCMP((char *)&(reg[EDX]), "enti", 4) == 0 &&
|
||||
XMEMCMP((char *)&(reg[ECX]), "cAMD", 4) == 0) {
|
||||
got_amd_cpu = 1;
|
||||
}
|
||||
|
||||
if (got_intel_cpu || got_amd_cpu) {
|
||||
cpuid(reg, leaf, sub);
|
||||
return ((reg[num] >> bit) & 0x1);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
void cpuid_set_flags(void)
|
||||
{
|
||||
if (!cpuid_check) {
|
||||
if (cpuid_flag(1, 0, ECX, 28)) { cpuid_flags |= CPUID_AVX1 ; }
|
||||
if (cpuid_flag(7, 0, EBX, 5)) { cpuid_flags |= CPUID_AVX2 ; }
|
||||
if (cpuid_flag(7, 0, EBX, 8)) { cpuid_flags |= CPUID_BMI2 ; }
|
||||
if (cpuid_flag(1, 0, ECX, 30)) { cpuid_flags |= CPUID_RDRAND; }
|
||||
if (cpuid_flag(7, 0, EBX, 18)) { cpuid_flags |= CPUID_RDSEED; }
|
||||
if (cpuid_flag(1, 0, ECX, 25)) { cpuid_flags |= CPUID_AESNI ; }
|
||||
if (cpuid_flag(7, 0, EBX, 19)) { cpuid_flags |= CPUID_ADX ; }
|
||||
if (cpuid_flag(1, 0, ECX, 22)) { cpuid_flags |= CPUID_MOVBE ; }
|
||||
cpuid_check = 1;
|
||||
}
|
||||
}
|
||||
|
||||
word32 cpuid_get_flags(void)
|
||||
{
|
||||
if (!cpuid_check)
|
||||
cpuid_set_flags();
|
||||
return cpuid_flags;
|
||||
}
|
||||
#endif
|
@ -1,649 +0,0 @@
|
||||
/* cryptocb.c
|
||||
*
|
||||
* Copyright (C) 2006-2020 wolfSSL Inc.
|
||||
*
|
||||
* This file is part of wolfSSL.
|
||||
*
|
||||
* wolfSSL is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* wolfSSL is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA
|
||||
*/
|
||||
|
||||
/* This framework provides a central place for crypto hardware integration
|
||||
using the devId scheme. If not supported return `CRYPTOCB_UNAVAILABLE`. */
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
#endif
|
||||
|
||||
#include <wolfssl/wolfcrypt/settings.h>
|
||||
|
||||
#ifdef WOLF_CRYPTO_CB
|
||||
|
||||
#include <wolfssl/wolfcrypt/cryptocb.h>
|
||||
#include <wolfssl/wolfcrypt/error-crypt.h>
|
||||
#include <wolfssl/wolfcrypt/logging.h>
|
||||
|
||||
|
||||
/* TODO: Consider linked list with mutex */
|
||||
#ifndef MAX_CRYPTO_DEVID_CALLBACKS
|
||||
#define MAX_CRYPTO_DEVID_CALLBACKS 8
|
||||
#endif
|
||||
|
||||
typedef struct CryptoCb {
|
||||
int devId;
|
||||
CryptoDevCallbackFunc cb;
|
||||
void* ctx;
|
||||
} CryptoCb;
|
||||
static WOLFSSL_GLOBAL CryptoCb gCryptoDev[MAX_CRYPTO_DEVID_CALLBACKS];
|
||||
|
||||
static CryptoCb* wc_CryptoCb_FindDevice(int devId)
|
||||
{
|
||||
int i;
|
||||
for (i=0; i<MAX_CRYPTO_DEVID_CALLBACKS; i++) {
|
||||
if (gCryptoDev[i].devId == devId)
|
||||
return &gCryptoDev[i];
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
static CryptoCb* wc_CryptoCb_FindDeviceByIndex(int startIdx)
|
||||
{
|
||||
int i;
|
||||
for (i=startIdx; i<MAX_CRYPTO_DEVID_CALLBACKS; i++) {
|
||||
if (gCryptoDev[i].devId != INVALID_DEVID)
|
||||
return &gCryptoDev[i];
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static WC_INLINE int wc_CryptoCb_TranslateErrorCode(int ret)
|
||||
{
|
||||
if (ret == NOT_COMPILED_IN) {
|
||||
/* backwards compatibility for older NOT_COMPILED_IN syntax */
|
||||
ret = CRYPTOCB_UNAVAILABLE;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
void wc_CryptoCb_Init(void)
|
||||
{
|
||||
int i;
|
||||
for (i=0; i<MAX_CRYPTO_DEVID_CALLBACKS; i++) {
|
||||
gCryptoDev[i].devId = INVALID_DEVID;
|
||||
}
|
||||
}
|
||||
|
||||
int wc_CryptoCb_RegisterDevice(int devId, CryptoDevCallbackFunc cb, void* ctx)
|
||||
{
|
||||
/* find existing or new */
|
||||
CryptoCb* dev = wc_CryptoCb_FindDevice(devId);
|
||||
if (dev == NULL)
|
||||
dev = wc_CryptoCb_FindDevice(INVALID_DEVID);
|
||||
|
||||
if (dev == NULL)
|
||||
return BUFFER_E; /* out of devices */
|
||||
|
||||
dev->devId = devId;
|
||||
dev->cb = cb;
|
||||
dev->ctx = ctx;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void wc_CryptoCb_UnRegisterDevice(int devId)
|
||||
{
|
||||
CryptoCb* dev = wc_CryptoCb_FindDevice(devId);
|
||||
if (dev) {
|
||||
XMEMSET(dev, 0, sizeof(*dev));
|
||||
dev->devId = INVALID_DEVID;
|
||||
}
|
||||
}
|
||||
|
||||
#ifndef NO_RSA
|
||||
int wc_CryptoCb_Rsa(const byte* in, word32 inLen, byte* out,
|
||||
word32* outLen, int type, RsaKey* key, WC_RNG* rng)
|
||||
{
|
||||
int ret = CRYPTOCB_UNAVAILABLE;
|
||||
CryptoCb* dev;
|
||||
|
||||
if (key == NULL)
|
||||
return ret;
|
||||
|
||||
/* locate registered callback */
|
||||
dev = wc_CryptoCb_FindDevice(key->devId);
|
||||
if (dev && dev->cb) {
|
||||
wc_CryptoInfo cryptoInfo;
|
||||
XMEMSET(&cryptoInfo, 0, sizeof(cryptoInfo));
|
||||
cryptoInfo.algo_type = WC_ALGO_TYPE_PK;
|
||||
cryptoInfo.pk.type = WC_PK_TYPE_RSA;
|
||||
cryptoInfo.pk.rsa.in = in;
|
||||
cryptoInfo.pk.rsa.inLen = inLen;
|
||||
cryptoInfo.pk.rsa.out = out;
|
||||
cryptoInfo.pk.rsa.outLen = outLen;
|
||||
cryptoInfo.pk.rsa.type = type;
|
||||
cryptoInfo.pk.rsa.key = key;
|
||||
cryptoInfo.pk.rsa.rng = rng;
|
||||
|
||||
ret = dev->cb(dev->devId, &cryptoInfo, dev->ctx);
|
||||
}
|
||||
|
||||
return wc_CryptoCb_TranslateErrorCode(ret);
|
||||
}
|
||||
|
||||
#ifdef WOLFSSL_KEY_GEN
|
||||
int wc_CryptoCb_MakeRsaKey(RsaKey* key, int size, long e, WC_RNG* rng)
|
||||
{
|
||||
int ret = CRYPTOCB_UNAVAILABLE;
|
||||
CryptoCb* dev;
|
||||
|
||||
if (key == NULL)
|
||||
return ret;
|
||||
|
||||
/* locate registered callback */
|
||||
dev = wc_CryptoCb_FindDevice(key->devId);
|
||||
if (dev && dev->cb) {
|
||||
wc_CryptoInfo cryptoInfo;
|
||||
XMEMSET(&cryptoInfo, 0, sizeof(cryptoInfo));
|
||||
cryptoInfo.algo_type = WC_ALGO_TYPE_PK;
|
||||
cryptoInfo.pk.type = WC_PK_TYPE_RSA_KEYGEN;
|
||||
cryptoInfo.pk.rsakg.key = key;
|
||||
cryptoInfo.pk.rsakg.size = size;
|
||||
cryptoInfo.pk.rsakg.e = e;
|
||||
cryptoInfo.pk.rsakg.rng = rng;
|
||||
|
||||
ret = dev->cb(dev->devId, &cryptoInfo, dev->ctx);
|
||||
}
|
||||
|
||||
return wc_CryptoCb_TranslateErrorCode(ret);
|
||||
}
|
||||
#endif
|
||||
#endif /* !NO_RSA */
|
||||
|
||||
#ifdef HAVE_ECC
|
||||
int wc_CryptoCb_MakeEccKey(WC_RNG* rng, int keySize, ecc_key* key, int curveId)
|
||||
{
|
||||
int ret = CRYPTOCB_UNAVAILABLE;
|
||||
CryptoCb* dev;
|
||||
|
||||
if (key == NULL)
|
||||
return ret;
|
||||
|
||||
/* locate registered callback */
|
||||
dev = wc_CryptoCb_FindDevice(key->devId);
|
||||
if (dev && dev->cb) {
|
||||
wc_CryptoInfo cryptoInfo;
|
||||
XMEMSET(&cryptoInfo, 0, sizeof(cryptoInfo));
|
||||
cryptoInfo.algo_type = WC_ALGO_TYPE_PK;
|
||||
cryptoInfo.pk.type = WC_PK_TYPE_EC_KEYGEN;
|
||||
cryptoInfo.pk.eckg.rng = rng;
|
||||
cryptoInfo.pk.eckg.size = keySize;
|
||||
cryptoInfo.pk.eckg.key = key;
|
||||
cryptoInfo.pk.eckg.curveId = curveId;
|
||||
|
||||
ret = dev->cb(dev->devId, &cryptoInfo, dev->ctx);
|
||||
}
|
||||
|
||||
return wc_CryptoCb_TranslateErrorCode(ret);
|
||||
}
|
||||
|
||||
int wc_CryptoCb_Ecdh(ecc_key* private_key, ecc_key* public_key,
|
||||
byte* out, word32* outlen)
|
||||
{
|
||||
int ret = CRYPTOCB_UNAVAILABLE;
|
||||
CryptoCb* dev;
|
||||
|
||||
if (private_key == NULL)
|
||||
return ret;
|
||||
|
||||
/* locate registered callback */
|
||||
dev = wc_CryptoCb_FindDevice(private_key->devId);
|
||||
if (dev && dev->cb) {
|
||||
wc_CryptoInfo cryptoInfo;
|
||||
XMEMSET(&cryptoInfo, 0, sizeof(cryptoInfo));
|
||||
cryptoInfo.algo_type = WC_ALGO_TYPE_PK;
|
||||
cryptoInfo.pk.type = WC_PK_TYPE_ECDH;
|
||||
cryptoInfo.pk.ecdh.private_key = private_key;
|
||||
cryptoInfo.pk.ecdh.public_key = public_key;
|
||||
cryptoInfo.pk.ecdh.out = out;
|
||||
cryptoInfo.pk.ecdh.outlen = outlen;
|
||||
|
||||
ret = dev->cb(dev->devId, &cryptoInfo, dev->ctx);
|
||||
}
|
||||
|
||||
return wc_CryptoCb_TranslateErrorCode(ret);
|
||||
}
|
||||
|
||||
int wc_CryptoCb_EccSign(const byte* in, word32 inlen, byte* out,
|
||||
word32 *outlen, WC_RNG* rng, ecc_key* key)
|
||||
{
|
||||
int ret = CRYPTOCB_UNAVAILABLE;
|
||||
CryptoCb* dev;
|
||||
|
||||
if (key == NULL)
|
||||
return ret;
|
||||
|
||||
/* locate registered callback */
|
||||
dev = wc_CryptoCb_FindDevice(key->devId);
|
||||
if (dev && dev->cb) {
|
||||
wc_CryptoInfo cryptoInfo;
|
||||
XMEMSET(&cryptoInfo, 0, sizeof(cryptoInfo));
|
||||
cryptoInfo.algo_type = WC_ALGO_TYPE_PK;
|
||||
cryptoInfo.pk.type = WC_PK_TYPE_ECDSA_SIGN;
|
||||
cryptoInfo.pk.eccsign.in = in;
|
||||
cryptoInfo.pk.eccsign.inlen = inlen;
|
||||
cryptoInfo.pk.eccsign.out = out;
|
||||
cryptoInfo.pk.eccsign.outlen = outlen;
|
||||
cryptoInfo.pk.eccsign.rng = rng;
|
||||
cryptoInfo.pk.eccsign.key = key;
|
||||
|
||||
ret = dev->cb(dev->devId, &cryptoInfo, dev->ctx);
|
||||
}
|
||||
|
||||
return wc_CryptoCb_TranslateErrorCode(ret);
|
||||
}
|
||||
|
||||
int wc_CryptoCb_EccVerify(const byte* sig, word32 siglen,
|
||||
const byte* hash, word32 hashlen, int* res, ecc_key* key)
|
||||
{
|
||||
int ret = CRYPTOCB_UNAVAILABLE;
|
||||
CryptoCb* dev;
|
||||
|
||||
if (key == NULL)
|
||||
return ret;
|
||||
|
||||
/* locate registered callback */
|
||||
dev = wc_CryptoCb_FindDevice(key->devId);
|
||||
if (dev && dev->cb) {
|
||||
wc_CryptoInfo cryptoInfo;
|
||||
XMEMSET(&cryptoInfo, 0, sizeof(cryptoInfo));
|
||||
cryptoInfo.algo_type = WC_ALGO_TYPE_PK;
|
||||
cryptoInfo.pk.type = WC_PK_TYPE_ECDSA_VERIFY;
|
||||
cryptoInfo.pk.eccverify.sig = sig;
|
||||
cryptoInfo.pk.eccverify.siglen = siglen;
|
||||
cryptoInfo.pk.eccverify.hash = hash;
|
||||
cryptoInfo.pk.eccverify.hashlen = hashlen;
|
||||
cryptoInfo.pk.eccverify.res = res;
|
||||
cryptoInfo.pk.eccverify.key = key;
|
||||
|
||||
ret = dev->cb(dev->devId, &cryptoInfo, dev->ctx);
|
||||
}
|
||||
|
||||
return wc_CryptoCb_TranslateErrorCode(ret);
|
||||
}
|
||||
#endif /* HAVE_ECC */
|
||||
|
||||
#ifndef NO_AES
|
||||
#ifdef HAVE_AESGCM
|
||||
int wc_CryptoCb_AesGcmEncrypt(Aes* aes, byte* out,
|
||||
const byte* in, word32 sz,
|
||||
const byte* iv, word32 ivSz,
|
||||
byte* authTag, word32 authTagSz,
|
||||
const byte* authIn, word32 authInSz)
|
||||
{
|
||||
int ret = CRYPTOCB_UNAVAILABLE;
|
||||
CryptoCb* dev;
|
||||
|
||||
/* locate registered callback */
|
||||
if (aes) {
|
||||
dev = wc_CryptoCb_FindDevice(aes->devId);
|
||||
}
|
||||
else {
|
||||
/* locate first callback and try using it */
|
||||
dev = wc_CryptoCb_FindDeviceByIndex(0);
|
||||
}
|
||||
|
||||
if (dev && dev->cb) {
|
||||
wc_CryptoInfo cryptoInfo;
|
||||
XMEMSET(&cryptoInfo, 0, sizeof(cryptoInfo));
|
||||
cryptoInfo.algo_type = WC_ALGO_TYPE_CIPHER;
|
||||
cryptoInfo.cipher.type = WC_CIPHER_AES_GCM;
|
||||
cryptoInfo.cipher.enc = 1;
|
||||
cryptoInfo.cipher.aesgcm_enc.aes = aes;
|
||||
cryptoInfo.cipher.aesgcm_enc.out = out;
|
||||
cryptoInfo.cipher.aesgcm_enc.in = in;
|
||||
cryptoInfo.cipher.aesgcm_enc.sz = sz;
|
||||
cryptoInfo.cipher.aesgcm_enc.iv = iv;
|
||||
cryptoInfo.cipher.aesgcm_enc.ivSz = ivSz;
|
||||
cryptoInfo.cipher.aesgcm_enc.authTag = authTag;
|
||||
cryptoInfo.cipher.aesgcm_enc.authTagSz = authTagSz;
|
||||
cryptoInfo.cipher.aesgcm_enc.authIn = authIn;
|
||||
cryptoInfo.cipher.aesgcm_enc.authInSz = authInSz;
|
||||
|
||||
ret = dev->cb(dev->devId, &cryptoInfo, dev->ctx);
|
||||
}
|
||||
|
||||
return wc_CryptoCb_TranslateErrorCode(ret);
|
||||
}
|
||||
|
||||
int wc_CryptoCb_AesGcmDecrypt(Aes* aes, byte* out,
|
||||
const byte* in, word32 sz,
|
||||
const byte* iv, word32 ivSz,
|
||||
const byte* authTag, word32 authTagSz,
|
||||
const byte* authIn, word32 authInSz)
|
||||
{
|
||||
int ret = CRYPTOCB_UNAVAILABLE;
|
||||
CryptoCb* dev;
|
||||
|
||||
/* locate registered callback */
|
||||
if (aes) {
|
||||
dev = wc_CryptoCb_FindDevice(aes->devId);
|
||||
}
|
||||
else {
|
||||
/* locate first callback and try using it */
|
||||
dev = wc_CryptoCb_FindDeviceByIndex(0);
|
||||
}
|
||||
|
||||
if (dev && dev->cb) {
|
||||
wc_CryptoInfo cryptoInfo;
|
||||
XMEMSET(&cryptoInfo, 0, sizeof(cryptoInfo));
|
||||
cryptoInfo.algo_type = WC_ALGO_TYPE_CIPHER;
|
||||
cryptoInfo.cipher.type = WC_CIPHER_AES_GCM;
|
||||
cryptoInfo.cipher.enc = 0;
|
||||
cryptoInfo.cipher.aesgcm_dec.aes = aes;
|
||||
cryptoInfo.cipher.aesgcm_dec.out = out;
|
||||
cryptoInfo.cipher.aesgcm_dec.in = in;
|
||||
cryptoInfo.cipher.aesgcm_dec.sz = sz;
|
||||
cryptoInfo.cipher.aesgcm_dec.iv = iv;
|
||||
cryptoInfo.cipher.aesgcm_dec.ivSz = ivSz;
|
||||
cryptoInfo.cipher.aesgcm_dec.authTag = authTag;
|
||||
cryptoInfo.cipher.aesgcm_dec.authTagSz = authTagSz;
|
||||
cryptoInfo.cipher.aesgcm_dec.authIn = authIn;
|
||||
cryptoInfo.cipher.aesgcm_dec.authInSz = authInSz;
|
||||
|
||||
ret = dev->cb(dev->devId, &cryptoInfo, dev->ctx);
|
||||
}
|
||||
|
||||
return wc_CryptoCb_TranslateErrorCode(ret);
|
||||
}
|
||||
#endif /* HAVE_AESGCM */
|
||||
|
||||
#ifdef HAVE_AES_CBC
|
||||
int wc_CryptoCb_AesCbcEncrypt(Aes* aes, byte* out,
|
||||
const byte* in, word32 sz)
|
||||
{
|
||||
int ret = CRYPTOCB_UNAVAILABLE;
|
||||
CryptoCb* dev;
|
||||
|
||||
/* locate registered callback */
|
||||
if (aes) {
|
||||
dev = wc_CryptoCb_FindDevice(aes->devId);
|
||||
}
|
||||
else {
|
||||
/* locate first callback and try using it */
|
||||
dev = wc_CryptoCb_FindDeviceByIndex(0);
|
||||
}
|
||||
|
||||
if (dev && dev->cb) {
|
||||
wc_CryptoInfo cryptoInfo;
|
||||
XMEMSET(&cryptoInfo, 0, sizeof(cryptoInfo));
|
||||
cryptoInfo.algo_type = WC_ALGO_TYPE_CIPHER;
|
||||
cryptoInfo.cipher.type = WC_CIPHER_AES_CBC;
|
||||
cryptoInfo.cipher.enc = 1;
|
||||
cryptoInfo.cipher.aescbc.aes = aes;
|
||||
cryptoInfo.cipher.aescbc.out = out;
|
||||
cryptoInfo.cipher.aescbc.in = in;
|
||||
cryptoInfo.cipher.aescbc.sz = sz;
|
||||
|
||||
ret = dev->cb(dev->devId, &cryptoInfo, dev->ctx);
|
||||
}
|
||||
|
||||
return wc_CryptoCb_TranslateErrorCode(ret);
|
||||
}
|
||||
|
||||
int wc_CryptoCb_AesCbcDecrypt(Aes* aes, byte* out,
|
||||
const byte* in, word32 sz)
|
||||
{
|
||||
int ret = CRYPTOCB_UNAVAILABLE;
|
||||
CryptoCb* dev;
|
||||
|
||||
/* locate registered callback */
|
||||
if (aes) {
|
||||
dev = wc_CryptoCb_FindDevice(aes->devId);
|
||||
}
|
||||
else {
|
||||
/* locate first callback and try using it */
|
||||
dev = wc_CryptoCb_FindDeviceByIndex(0);
|
||||
}
|
||||
|
||||
if (dev && dev->cb) {
|
||||
wc_CryptoInfo cryptoInfo;
|
||||
XMEMSET(&cryptoInfo, 0, sizeof(cryptoInfo));
|
||||
cryptoInfo.algo_type = WC_ALGO_TYPE_CIPHER;
|
||||
cryptoInfo.cipher.type = WC_CIPHER_AES_CBC;
|
||||
cryptoInfo.cipher.enc = 0;
|
||||
cryptoInfo.cipher.aescbc.aes = aes;
|
||||
cryptoInfo.cipher.aescbc.out = out;
|
||||
cryptoInfo.cipher.aescbc.in = in;
|
||||
cryptoInfo.cipher.aescbc.sz = sz;
|
||||
|
||||
ret = dev->cb(dev->devId, &cryptoInfo, dev->ctx);
|
||||
}
|
||||
|
||||
return wc_CryptoCb_TranslateErrorCode(ret);
|
||||
}
|
||||
#endif /* HAVE_AES_CBC */
|
||||
#endif /* !NO_AES */
|
||||
|
||||
#ifndef NO_DES3
|
||||
int wc_CryptoCb_Des3Encrypt(Des3* des3, byte* out,
|
||||
const byte* in, word32 sz)
|
||||
{
|
||||
int ret = CRYPTOCB_UNAVAILABLE;
|
||||
CryptoCb* dev;
|
||||
|
||||
/* locate registered callback */
|
||||
if (des3) {
|
||||
dev = wc_CryptoCb_FindDevice(des3->devId);
|
||||
}
|
||||
else {
|
||||
/* locate first callback and try using it */
|
||||
dev = wc_CryptoCb_FindDeviceByIndex(0);
|
||||
}
|
||||
|
||||
if (dev && dev->cb) {
|
||||
wc_CryptoInfo cryptoInfo;
|
||||
XMEMSET(&cryptoInfo, 0, sizeof(cryptoInfo));
|
||||
cryptoInfo.algo_type = WC_ALGO_TYPE_CIPHER;
|
||||
cryptoInfo.cipher.type = WC_CIPHER_DES3;
|
||||
cryptoInfo.cipher.enc = 1;
|
||||
cryptoInfo.cipher.des3.des = des3;
|
||||
cryptoInfo.cipher.des3.out = out;
|
||||
cryptoInfo.cipher.des3.in = in;
|
||||
cryptoInfo.cipher.des3.sz = sz;
|
||||
|
||||
ret = dev->cb(dev->devId, &cryptoInfo, dev->ctx);
|
||||
}
|
||||
|
||||
return wc_CryptoCb_TranslateErrorCode(ret);
|
||||
}
|
||||
|
||||
int wc_CryptoCb_Des3Decrypt(Des3* des3, byte* out,
|
||||
const byte* in, word32 sz)
|
||||
{
|
||||
int ret = CRYPTOCB_UNAVAILABLE;
|
||||
CryptoCb* dev;
|
||||
|
||||
/* locate registered callback */
|
||||
if (des3) {
|
||||
dev = wc_CryptoCb_FindDevice(des3->devId);
|
||||
}
|
||||
else {
|
||||
/* locate first callback and try using it */
|
||||
dev = wc_CryptoCb_FindDeviceByIndex(0);
|
||||
}
|
||||
|
||||
if (dev && dev->cb) {
|
||||
wc_CryptoInfo cryptoInfo;
|
||||
XMEMSET(&cryptoInfo, 0, sizeof(cryptoInfo));
|
||||
cryptoInfo.algo_type = WC_ALGO_TYPE_CIPHER;
|
||||
cryptoInfo.cipher.type = WC_CIPHER_DES3;
|
||||
cryptoInfo.cipher.enc = 0;
|
||||
cryptoInfo.cipher.des3.des = des3;
|
||||
cryptoInfo.cipher.des3.out = out;
|
||||
cryptoInfo.cipher.des3.in = in;
|
||||
cryptoInfo.cipher.des3.sz = sz;
|
||||
|
||||
ret = dev->cb(dev->devId, &cryptoInfo, dev->ctx);
|
||||
}
|
||||
|
||||
return wc_CryptoCb_TranslateErrorCode(ret);
|
||||
}
|
||||
#endif /* !NO_DES3 */
|
||||
|
||||
#ifndef NO_SHA
|
||||
int wc_CryptoCb_ShaHash(wc_Sha* sha, const byte* in,
|
||||
word32 inSz, byte* digest)
|
||||
{
|
||||
int ret = CRYPTOCB_UNAVAILABLE;
|
||||
CryptoCb* dev;
|
||||
|
||||
/* locate registered callback */
|
||||
if (sha) {
|
||||
dev = wc_CryptoCb_FindDevice(sha->devId);
|
||||
}
|
||||
else {
|
||||
/* locate first callback and try using it */
|
||||
dev = wc_CryptoCb_FindDeviceByIndex(0);
|
||||
}
|
||||
|
||||
if (dev && dev->cb) {
|
||||
wc_CryptoInfo cryptoInfo;
|
||||
XMEMSET(&cryptoInfo, 0, sizeof(cryptoInfo));
|
||||
cryptoInfo.algo_type = WC_ALGO_TYPE_HASH;
|
||||
cryptoInfo.hash.type = WC_HASH_TYPE_SHA;
|
||||
cryptoInfo.hash.sha1 = sha;
|
||||
cryptoInfo.hash.in = in;
|
||||
cryptoInfo.hash.inSz = inSz;
|
||||
cryptoInfo.hash.digest = digest;
|
||||
|
||||
ret = dev->cb(dev->devId, &cryptoInfo, dev->ctx);
|
||||
}
|
||||
|
||||
return wc_CryptoCb_TranslateErrorCode(ret);
|
||||
}
|
||||
#endif /* !NO_SHA */
|
||||
|
||||
#ifndef NO_SHA256
|
||||
int wc_CryptoCb_Sha256Hash(wc_Sha256* sha256, const byte* in,
|
||||
word32 inSz, byte* digest)
|
||||
{
|
||||
int ret = CRYPTOCB_UNAVAILABLE;
|
||||
CryptoCb* dev;
|
||||
|
||||
/* locate registered callback */
|
||||
if (sha256) {
|
||||
dev = wc_CryptoCb_FindDevice(sha256->devId);
|
||||
}
|
||||
else {
|
||||
/* locate first callback and try using it */
|
||||
dev = wc_CryptoCb_FindDeviceByIndex(0);
|
||||
}
|
||||
|
||||
if (dev && dev->cb) {
|
||||
wc_CryptoInfo cryptoInfo;
|
||||
XMEMSET(&cryptoInfo, 0, sizeof(cryptoInfo));
|
||||
cryptoInfo.algo_type = WC_ALGO_TYPE_HASH;
|
||||
cryptoInfo.hash.type = WC_HASH_TYPE_SHA256;
|
||||
cryptoInfo.hash.sha256 = sha256;
|
||||
cryptoInfo.hash.in = in;
|
||||
cryptoInfo.hash.inSz = inSz;
|
||||
cryptoInfo.hash.digest = digest;
|
||||
|
||||
ret = dev->cb(dev->devId, &cryptoInfo, dev->ctx);
|
||||
}
|
||||
|
||||
return wc_CryptoCb_TranslateErrorCode(ret);
|
||||
}
|
||||
#endif /* !NO_SHA256 */
|
||||
|
||||
#ifndef NO_HMAC
|
||||
int wc_CryptoCb_Hmac(Hmac* hmac, int macType, const byte* in, word32 inSz,
|
||||
byte* digest)
|
||||
{
|
||||
int ret = CRYPTOCB_UNAVAILABLE;
|
||||
CryptoCb* dev;
|
||||
|
||||
if (hmac == NULL)
|
||||
return ret;
|
||||
|
||||
/* locate registered callback */
|
||||
dev = wc_CryptoCb_FindDevice(hmac->devId);
|
||||
if (dev && dev->cb) {
|
||||
wc_CryptoInfo cryptoInfo;
|
||||
XMEMSET(&cryptoInfo, 0, sizeof(cryptoInfo));
|
||||
cryptoInfo.algo_type = WC_ALGO_TYPE_HMAC;
|
||||
cryptoInfo.hmac.macType = macType;
|
||||
cryptoInfo.hmac.in = in;
|
||||
cryptoInfo.hmac.inSz = inSz;
|
||||
cryptoInfo.hmac.digest = digest;
|
||||
cryptoInfo.hmac.hmac = hmac;
|
||||
|
||||
ret = dev->cb(dev->devId, &cryptoInfo, dev->ctx);
|
||||
}
|
||||
|
||||
return wc_CryptoCb_TranslateErrorCode(ret);
|
||||
}
|
||||
#endif /* !NO_HMAC */
|
||||
|
||||
#ifndef WC_NO_RNG
|
||||
int wc_CryptoCb_RandomBlock(WC_RNG* rng, byte* out, word32 sz)
|
||||
{
|
||||
int ret = CRYPTOCB_UNAVAILABLE;
|
||||
CryptoCb* dev;
|
||||
|
||||
/* locate registered callback */
|
||||
if (rng) {
|
||||
dev = wc_CryptoCb_FindDevice(rng->devId);
|
||||
}
|
||||
else {
|
||||
/* locate first callback and try using it */
|
||||
dev = wc_CryptoCb_FindDeviceByIndex(0);
|
||||
}
|
||||
|
||||
if (dev && dev->cb) {
|
||||
wc_CryptoInfo cryptoInfo;
|
||||
XMEMSET(&cryptoInfo, 0, sizeof(cryptoInfo));
|
||||
cryptoInfo.algo_type = WC_ALGO_TYPE_RNG;
|
||||
cryptoInfo.rng.rng = rng;
|
||||
cryptoInfo.rng.out = out;
|
||||
cryptoInfo.rng.sz = sz;
|
||||
|
||||
ret = dev->cb(dev->devId, &cryptoInfo, dev->ctx);
|
||||
}
|
||||
|
||||
return wc_CryptoCb_TranslateErrorCode(ret);
|
||||
}
|
||||
|
||||
int wc_CryptoCb_RandomSeed(OS_Seed* os, byte* seed, word32 sz)
|
||||
{
|
||||
int ret = CRYPTOCB_UNAVAILABLE;
|
||||
CryptoCb* dev;
|
||||
|
||||
/* locate registered callback */
|
||||
dev = wc_CryptoCb_FindDevice(os->devId);
|
||||
if (dev && dev->cb) {
|
||||
wc_CryptoInfo cryptoInfo;
|
||||
XMEMSET(&cryptoInfo, 0, sizeof(cryptoInfo));
|
||||
cryptoInfo.algo_type = WC_ALGO_TYPE_SEED;
|
||||
cryptoInfo.seed.os = os;
|
||||
cryptoInfo.seed.seed = seed;
|
||||
cryptoInfo.seed.sz = sz;
|
||||
|
||||
ret = dev->cb(dev->devId, &cryptoInfo, dev->ctx);
|
||||
}
|
||||
|
||||
return wc_CryptoCb_TranslateErrorCode(ret);
|
||||
}
|
||||
#endif /* !WC_NO_RNG */
|
||||
|
||||
#endif /* WOLF_CRYPTO_CB */
|
@ -1,532 +0,0 @@
|
||||
/* curve25519.c
|
||||
*
|
||||
* Copyright (C) 2006-2020 wolfSSL Inc.
|
||||
*
|
||||
* This file is part of wolfSSL.
|
||||
*
|
||||
* wolfSSL is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* wolfSSL is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA
|
||||
*/
|
||||
|
||||
|
||||
/* Based On Daniel J Bernstein's curve25519 Public Domain ref10 work. */
|
||||
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
#endif
|
||||
|
||||
#include <wolfssl/wolfcrypt/settings.h>
|
||||
|
||||
#ifdef HAVE_CURVE25519
|
||||
|
||||
#include <wolfssl/wolfcrypt/curve25519.h>
|
||||
#include <wolfssl/wolfcrypt/error-crypt.h>
|
||||
#ifdef NO_INLINE
|
||||
#include <wolfssl/wolfcrypt/misc.h>
|
||||
#else
|
||||
#define WOLFSSL_MISC_INCLUDED
|
||||
#include <wolfcrypt/src/misc.c>
|
||||
#endif
|
||||
|
||||
#if defined(FREESCALE_LTC_ECC)
|
||||
#include <wolfssl/wolfcrypt/port/nxp/ksdk_port.h>
|
||||
#endif
|
||||
|
||||
const curve25519_set_type curve25519_sets[] = {
|
||||
{
|
||||
CURVE25519_KEYSIZE,
|
||||
"CURVE25519",
|
||||
}
|
||||
};
|
||||
|
||||
static const unsigned char kCurve25519BasePoint[CURVE25519_KEYSIZE] = {9};
|
||||
|
||||
/* compute the public key from an existing private key, using bare vectors.
|
||||
*
|
||||
* return value is propagated from curve25519() (0 on success), or ECC_BAD_ARG_E,
|
||||
* and the byte vectors are little endian.
|
||||
*/
|
||||
int wc_curve25519_make_pub(int public_size, byte* pub, int private_size,
|
||||
const byte* priv) {
|
||||
int ret;
|
||||
|
||||
if ((public_size != CURVE25519_KEYSIZE) ||
|
||||
(private_size != CURVE25519_KEYSIZE)) {
|
||||
return ECC_BAD_ARG_E;
|
||||
}
|
||||
if ((pub == NULL) || (priv == NULL))
|
||||
return ECC_BAD_ARG_E;
|
||||
|
||||
/* check clamping */
|
||||
if ((priv[0] & ~248) ||
|
||||
(priv[CURVE25519_KEYSIZE-1] & 128)) {
|
||||
return ECC_BAD_ARG_E;
|
||||
}
|
||||
|
||||
#ifdef FREESCALE_LTC_ECC
|
||||
{
|
||||
const ECPoint* basepoint = nxp_ltc_curve25519_GetBasePoint();
|
||||
ECPoint wc_pub;
|
||||
ret = nxp_ltc_curve25519(&wc_pub, priv, basepoint, kLTC_Weierstrass); /* input basepoint on Weierstrass curve */
|
||||
if (ret == 0)
|
||||
XMEMCPY(pub, wc_pub.point, CURVE25519_KEYSIZE);
|
||||
}
|
||||
#else
|
||||
fe_init();
|
||||
ret = curve25519(pub, priv, kCurve25519BasePoint);
|
||||
#endif
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
int wc_curve25519_make_key(WC_RNG* rng, int keysize, curve25519_key* key)
|
||||
{
|
||||
int ret;
|
||||
|
||||
if (key == NULL || rng == NULL)
|
||||
return BAD_FUNC_ARG;
|
||||
|
||||
/* currently only a key size of 32 bytes is used */
|
||||
if (keysize != CURVE25519_KEYSIZE)
|
||||
return ECC_BAD_ARG_E;
|
||||
|
||||
/* random number for private key */
|
||||
ret = wc_RNG_GenerateBlock(rng, key->k.point, keysize);
|
||||
if (ret != 0)
|
||||
return ret;
|
||||
|
||||
/* Clamp the private key */
|
||||
key->k.point[0] &= 248;
|
||||
key->k.point[CURVE25519_KEYSIZE-1] &= 63; /* same &=127 because |=64 after */
|
||||
key->k.point[CURVE25519_KEYSIZE-1] |= 64;
|
||||
|
||||
return wc_curve25519_make_pub((int)sizeof key->p.point, key->p.point, sizeof key->k.point, key->k.point);
|
||||
}
|
||||
|
||||
#ifdef HAVE_CURVE25519_SHARED_SECRET
|
||||
|
||||
int wc_curve25519_shared_secret(curve25519_key* private_key,
|
||||
curve25519_key* public_key,
|
||||
byte* out, word32* outlen)
|
||||
{
|
||||
return wc_curve25519_shared_secret_ex(private_key, public_key,
|
||||
out, outlen, EC25519_BIG_ENDIAN);
|
||||
}
|
||||
|
||||
int wc_curve25519_shared_secret_ex(curve25519_key* private_key,
|
||||
curve25519_key* public_key,
|
||||
byte* out, word32* outlen, int endian)
|
||||
{
|
||||
#ifdef FREESCALE_LTC_ECC
|
||||
ECPoint o = {{0}};
|
||||
#else
|
||||
unsigned char o[CURVE25519_KEYSIZE];
|
||||
#endif
|
||||
int ret = 0;
|
||||
|
||||
/* sanity check */
|
||||
if (private_key == NULL || public_key == NULL ||
|
||||
out == NULL || outlen == NULL || *outlen < CURVE25519_KEYSIZE)
|
||||
return BAD_FUNC_ARG;
|
||||
|
||||
/* avoid implementation fingerprinting */
|
||||
if (public_key->p.point[CURVE25519_KEYSIZE-1] > 0x7F)
|
||||
return ECC_BAD_ARG_E;
|
||||
|
||||
#ifdef FREESCALE_LTC_ECC
|
||||
ret = nxp_ltc_curve25519(&o, private_key->k.point, &public_key->p, kLTC_Curve25519 /* input point P on Curve25519 */);
|
||||
#else
|
||||
ret = curve25519(o, private_key->k.point, public_key->p.point);
|
||||
#endif
|
||||
if (ret != 0) {
|
||||
#ifdef FREESCALE_LTC_ECC
|
||||
ForceZero(o.point, CURVE25519_KEYSIZE);
|
||||
ForceZero(o.pointY, CURVE25519_KEYSIZE);
|
||||
#else
|
||||
ForceZero(o, CURVE25519_KEYSIZE);
|
||||
#endif
|
||||
return ret;
|
||||
}
|
||||
|
||||
if (endian == EC25519_BIG_ENDIAN) {
|
||||
int i;
|
||||
/* put shared secret key in Big Endian format */
|
||||
for (i = 0; i < CURVE25519_KEYSIZE; i++)
|
||||
#ifdef FREESCALE_LTC_ECC
|
||||
out[i] = o.point[CURVE25519_KEYSIZE - i -1];
|
||||
#else
|
||||
out[i] = o[CURVE25519_KEYSIZE - i -1];
|
||||
#endif
|
||||
}
|
||||
else /* put shared secret key in Little Endian format */
|
||||
#ifdef FREESCALE_LTC_ECC
|
||||
XMEMCPY(out, o.point, CURVE25519_KEYSIZE);
|
||||
#else
|
||||
XMEMCPY(out, o, CURVE25519_KEYSIZE);
|
||||
#endif
|
||||
|
||||
*outlen = CURVE25519_KEYSIZE;
|
||||
|
||||
#ifdef FREESCALE_LTC_ECC
|
||||
ForceZero(o.point, CURVE25519_KEYSIZE);
|
||||
ForceZero(o.pointY, CURVE25519_KEYSIZE);
|
||||
#else
|
||||
ForceZero(o, CURVE25519_KEYSIZE);
|
||||
#endif
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
#endif /* HAVE_CURVE25519_SHARED_SECRET */
|
||||
|
||||
#ifdef HAVE_CURVE25519_KEY_EXPORT
|
||||
|
||||
/* export curve25519 public key (Big endian)
|
||||
* return 0 on success */
|
||||
int wc_curve25519_export_public(curve25519_key* key, byte* out, word32* outLen)
|
||||
{
|
||||
return wc_curve25519_export_public_ex(key, out, outLen, EC25519_BIG_ENDIAN);
|
||||
}
|
||||
|
||||
/* export curve25519 public key (Big or Little endian)
|
||||
* return 0 on success */
|
||||
int wc_curve25519_export_public_ex(curve25519_key* key, byte* out,
|
||||
word32* outLen, int endian)
|
||||
{
|
||||
if (key == NULL || out == NULL || outLen == NULL)
|
||||
return BAD_FUNC_ARG;
|
||||
|
||||
/* check and set outgoing key size */
|
||||
if (*outLen < CURVE25519_KEYSIZE) {
|
||||
*outLen = CURVE25519_KEYSIZE;
|
||||
return ECC_BAD_ARG_E;
|
||||
}
|
||||
*outLen = CURVE25519_KEYSIZE;
|
||||
|
||||
if (endian == EC25519_BIG_ENDIAN) {
|
||||
int i;
|
||||
|
||||
/* read keys in Big Endian format */
|
||||
for (i = 0; i < CURVE25519_KEYSIZE; i++)
|
||||
out[i] = key->p.point[CURVE25519_KEYSIZE - i - 1];
|
||||
}
|
||||
else
|
||||
XMEMCPY(out, key->p.point, CURVE25519_KEYSIZE);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif /* HAVE_CURVE25519_KEY_EXPORT */
|
||||
|
||||
#ifdef HAVE_CURVE25519_KEY_IMPORT
|
||||
|
||||
/* import curve25519 public key (Big endian)
|
||||
* return 0 on success */
|
||||
int wc_curve25519_import_public(const byte* in, word32 inLen,
|
||||
curve25519_key* key)
|
||||
{
|
||||
return wc_curve25519_import_public_ex(in, inLen, key, EC25519_BIG_ENDIAN);
|
||||
}
|
||||
|
||||
/* import curve25519 public key (Big or Little endian)
|
||||
* return 0 on success */
|
||||
int wc_curve25519_import_public_ex(const byte* in, word32 inLen,
|
||||
curve25519_key* key, int endian)
|
||||
{
|
||||
/* sanity check */
|
||||
if (key == NULL || in == NULL)
|
||||
return BAD_FUNC_ARG;
|
||||
|
||||
/* check size of incoming keys */
|
||||
if (inLen != CURVE25519_KEYSIZE)
|
||||
return ECC_BAD_ARG_E;
|
||||
|
||||
if (endian == EC25519_BIG_ENDIAN) {
|
||||
int i;
|
||||
|
||||
/* read keys in Big Endian format */
|
||||
for (i = 0; i < CURVE25519_KEYSIZE; i++)
|
||||
key->p.point[i] = in[CURVE25519_KEYSIZE - i - 1];
|
||||
}
|
||||
else
|
||||
XMEMCPY(key->p.point, in, inLen);
|
||||
|
||||
key->dp = &curve25519_sets[0];
|
||||
|
||||
/* LTC needs also Y coordinate - let's compute it */
|
||||
#ifdef FREESCALE_LTC_ECC
|
||||
ltc_pkha_ecc_point_t ltcPoint;
|
||||
ltcPoint.X = &key->p.point[0];
|
||||
ltcPoint.Y = &key->p.pointY[0];
|
||||
LTC_PKHA_Curve25519ComputeY(<cPoint);
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Check the public key value (big or little endian)
|
||||
*
|
||||
* pub Public key bytes.
|
||||
* pubSz Size of public key in bytes.
|
||||
* endian Public key bytes passed in as big-endian or little-endian.
|
||||
* returns BAD_FUNC_ARGS when pub is NULL,
|
||||
* BUFFER_E when size of public key is zero;
|
||||
* ECC_OUT_OF_RANGE_E if the high bit is set;
|
||||
* ECC_BAD_ARG_E if key length is not 32 bytes, public key value is
|
||||
* zero or one; and
|
||||
* 0 otherwise.
|
||||
*/
|
||||
int wc_curve25519_check_public(const byte* pub, word32 pubSz, int endian)
|
||||
{
|
||||
word32 i;
|
||||
|
||||
if (pub == NULL)
|
||||
return BAD_FUNC_ARG;
|
||||
|
||||
/* Check for empty key data */
|
||||
if (pubSz == 0)
|
||||
return BUFFER_E;
|
||||
|
||||
/* Check key length */
|
||||
if (pubSz != CURVE25519_KEYSIZE)
|
||||
return ECC_BAD_ARG_E;
|
||||
|
||||
|
||||
if (endian == EC25519_LITTLE_ENDIAN) {
|
||||
/* Check for value of zero or one */
|
||||
for (i = pubSz - 1; i > 0; i--) {
|
||||
if (pub[i] != 0)
|
||||
break;
|
||||
}
|
||||
if (i == 0 && (pub[0] == 0 || pub[0] == 1))
|
||||
return ECC_BAD_ARG_E;
|
||||
|
||||
/* Check high bit set */
|
||||
if (pub[CURVE25519_KEYSIZE-1] & 0x80)
|
||||
return ECC_OUT_OF_RANGE_E;
|
||||
}
|
||||
else {
|
||||
/* Check for value of zero or one */
|
||||
for (i = 0; i < pubSz-1; i++) {
|
||||
if (pub[i] != 0)
|
||||
break;
|
||||
}
|
||||
if (i == pubSz - 1 && (pub[i] == 0 || pub[i] == 1))
|
||||
return ECC_BAD_ARG_E;
|
||||
|
||||
/* Check high bit set */
|
||||
if (pub[0] & 0x80)
|
||||
return ECC_OUT_OF_RANGE_E;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif /* HAVE_CURVE25519_KEY_IMPORT */
|
||||
|
||||
|
||||
#ifdef HAVE_CURVE25519_KEY_EXPORT
|
||||
|
||||
/* export curve25519 private key only raw (Big endian)
|
||||
* outLen is in/out size
|
||||
* return 0 on success */
|
||||
int wc_curve25519_export_private_raw(curve25519_key* key, byte* out,
|
||||
word32* outLen)
|
||||
{
|
||||
return wc_curve25519_export_private_raw_ex(key, out, outLen,
|
||||
EC25519_BIG_ENDIAN);
|
||||
}
|
||||
|
||||
/* export curve25519 private key only raw (Big or Little endian)
|
||||
* outLen is in/out size
|
||||
* return 0 on success */
|
||||
int wc_curve25519_export_private_raw_ex(curve25519_key* key, byte* out,
|
||||
word32* outLen, int endian)
|
||||
{
|
||||
/* sanity check */
|
||||
if (key == NULL || out == NULL || outLen == NULL)
|
||||
return BAD_FUNC_ARG;
|
||||
|
||||
/* check size of outgoing buffer */
|
||||
if (*outLen < CURVE25519_KEYSIZE) {
|
||||
*outLen = CURVE25519_KEYSIZE;
|
||||
return ECC_BAD_ARG_E;
|
||||
}
|
||||
*outLen = CURVE25519_KEYSIZE;
|
||||
|
||||
if (endian == EC25519_BIG_ENDIAN) {
|
||||
int i;
|
||||
|
||||
/* put the key in Big Endian format */
|
||||
for (i = 0; i < CURVE25519_KEYSIZE; i++)
|
||||
out[i] = key->k.point[CURVE25519_KEYSIZE - i - 1];
|
||||
}
|
||||
else
|
||||
XMEMCPY(out, key->k.point, CURVE25519_KEYSIZE);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* curve25519 key pair export (Big or Little endian)
|
||||
* return 0 on success */
|
||||
int wc_curve25519_export_key_raw(curve25519_key* key,
|
||||
byte* priv, word32 *privSz,
|
||||
byte* pub, word32 *pubSz)
|
||||
{
|
||||
return wc_curve25519_export_key_raw_ex(key, priv, privSz,
|
||||
pub, pubSz, EC25519_BIG_ENDIAN);
|
||||
}
|
||||
|
||||
/* curve25519 key pair export (Big or Little endian)
|
||||
* return 0 on success */
|
||||
int wc_curve25519_export_key_raw_ex(curve25519_key* key,
|
||||
byte* priv, word32 *privSz,
|
||||
byte* pub, word32 *pubSz,
|
||||
int endian)
|
||||
{
|
||||
int ret;
|
||||
|
||||
/* export private part */
|
||||
ret = wc_curve25519_export_private_raw_ex(key, priv, privSz, endian);
|
||||
if (ret != 0)
|
||||
return ret;
|
||||
|
||||
/* export public part */
|
||||
return wc_curve25519_export_public_ex(key, pub, pubSz, endian);
|
||||
}
|
||||
|
||||
#endif /* HAVE_CURVE25519_KEY_EXPORT */
|
||||
|
||||
#ifdef HAVE_CURVE25519_KEY_IMPORT
|
||||
|
||||
/* curve25519 private key import (Big endian)
|
||||
* Public key to match private key needs to be imported too
|
||||
* return 0 on success */
|
||||
int wc_curve25519_import_private_raw(const byte* priv, word32 privSz,
|
||||
const byte* pub, word32 pubSz,
|
||||
curve25519_key* key)
|
||||
{
|
||||
return wc_curve25519_import_private_raw_ex(priv, privSz, pub, pubSz,
|
||||
key, EC25519_BIG_ENDIAN);
|
||||
}
|
||||
|
||||
/* curve25519 private key import (Big or Little endian)
|
||||
* Public key to match private key needs to be imported too
|
||||
* return 0 on success */
|
||||
int wc_curve25519_import_private_raw_ex(const byte* priv, word32 privSz,
|
||||
const byte* pub, word32 pubSz,
|
||||
curve25519_key* key, int endian)
|
||||
{
|
||||
int ret;
|
||||
|
||||
/* import private part */
|
||||
ret = wc_curve25519_import_private_ex(priv, privSz, key, endian);
|
||||
if (ret != 0)
|
||||
return ret;
|
||||
|
||||
/* import public part */
|
||||
return wc_curve25519_import_public_ex(pub, pubSz, key, endian);
|
||||
}
|
||||
|
||||
/* curve25519 private key import only. (Big endian)
|
||||
* return 0 on success */
|
||||
int wc_curve25519_import_private(const byte* priv, word32 privSz,
|
||||
curve25519_key* key)
|
||||
{
|
||||
return wc_curve25519_import_private_ex(priv, privSz,
|
||||
key, EC25519_BIG_ENDIAN);
|
||||
}
|
||||
|
||||
/* curve25519 private key import only. (Big or Little endian)
|
||||
* return 0 on success */
|
||||
int wc_curve25519_import_private_ex(const byte* priv, word32 privSz,
|
||||
curve25519_key* key, int endian)
|
||||
{
|
||||
/* sanity check */
|
||||
if (key == NULL || priv == NULL)
|
||||
return BAD_FUNC_ARG;
|
||||
|
||||
/* check size of incoming keys */
|
||||
if ((int)privSz != CURVE25519_KEYSIZE)
|
||||
return ECC_BAD_ARG_E;
|
||||
|
||||
if (endian == EC25519_BIG_ENDIAN) {
|
||||
int i;
|
||||
|
||||
/* read the key in Big Endian format */
|
||||
for (i = 0; i < CURVE25519_KEYSIZE; i++)
|
||||
key->k.point[i] = priv[CURVE25519_KEYSIZE - i - 1];
|
||||
}
|
||||
else
|
||||
XMEMCPY(key->k.point, priv, CURVE25519_KEYSIZE);
|
||||
|
||||
key->dp = &curve25519_sets[0];
|
||||
|
||||
/* Clamp the key */
|
||||
key->k.point[0] &= 248;
|
||||
key->k.point[privSz-1] &= 63; /* same &=127 because |=64 after */
|
||||
key->k.point[privSz-1] |= 64;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif /* HAVE_CURVE25519_KEY_IMPORT */
|
||||
|
||||
|
||||
int wc_curve25519_init(curve25519_key* key)
|
||||
{
|
||||
if (key == NULL)
|
||||
return BAD_FUNC_ARG;
|
||||
|
||||
XMEMSET(key, 0, sizeof(*key));
|
||||
|
||||
/* currently the format for curve25519 */
|
||||
key->dp = &curve25519_sets[0];
|
||||
|
||||
#ifndef FREESCALE_LTC_ECC
|
||||
fe_init();
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/* Clean the memory of a key */
|
||||
void wc_curve25519_free(curve25519_key* key)
|
||||
{
|
||||
if (key == NULL)
|
||||
return;
|
||||
|
||||
key->dp = NULL;
|
||||
ForceZero(key->p.point, sizeof(key->p.point));
|
||||
ForceZero(key->k.point, sizeof(key->k.point));
|
||||
#ifdef FREESCALE_LTC_ECC
|
||||
ForceZero(key->p.point, sizeof(key->p.pointY));
|
||||
ForceZero(key->k.point, sizeof(key->k.pointY));
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
/* get key size */
|
||||
int wc_curve25519_size(curve25519_key* key)
|
||||
{
|
||||
if (key == NULL)
|
||||
return 0;
|
||||
|
||||
return key->dp->size;
|
||||
}
|
||||
|
||||
#endif /*HAVE_CURVE25519*/
|
||||
|
@ -1,635 +0,0 @@
|
||||
/* curve448.c
|
||||
*
|
||||
* Copyright (C) 2006-2020 wolfSSL Inc.
|
||||
*
|
||||
* This file is part of wolfSSL.
|
||||
*
|
||||
* wolfSSL is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* wolfSSL is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA
|
||||
*/
|
||||
|
||||
/* Implemented to: RFC 7748 */
|
||||
|
||||
/* Based On Daniel J Bernstein's curve25519 Public Domain ref10 work.
|
||||
* Reworked for curve448 by Sean Parkinson.
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
#endif
|
||||
|
||||
#include <wolfssl/wolfcrypt/settings.h>
|
||||
|
||||
#ifdef HAVE_CURVE448
|
||||
|
||||
#include <wolfssl/wolfcrypt/curve448.h>
|
||||
#include <wolfssl/wolfcrypt/error-crypt.h>
|
||||
#ifdef NO_INLINE
|
||||
#include <wolfssl/wolfcrypt/misc.h>
|
||||
#else
|
||||
#define WOLFSSL_MISC_INCLUDED
|
||||
#include <wolfcrypt/src/misc.c>
|
||||
#endif
|
||||
|
||||
|
||||
/* Make a new curve448 private/public key.
|
||||
*
|
||||
* rng [in] Random number generator.
|
||||
* keysize [in] Size of the key to generate.
|
||||
* key [in] Curve448 key object.
|
||||
* returns BAD_FUNC_ARG when rng or key are NULL,
|
||||
* ECC_BAD_ARG_E when keysize is not CURVE448_KEY_SIZE,
|
||||
* 0 otherwise.
|
||||
*/
|
||||
int wc_curve448_make_key(WC_RNG* rng, int keysize, curve448_key* key)
|
||||
{
|
||||
unsigned char basepoint[CURVE448_KEY_SIZE] = {5};
|
||||
int ret = 0;
|
||||
|
||||
if ((key == NULL) || (rng == NULL)) {
|
||||
ret = BAD_FUNC_ARG;
|
||||
}
|
||||
|
||||
/* currently only a key size of 56 bytes is used */
|
||||
if ((ret == 0) && (keysize != CURVE448_KEY_SIZE)) {
|
||||
ret = ECC_BAD_ARG_E;
|
||||
}
|
||||
|
||||
if (ret == 0) {
|
||||
fe448_init();
|
||||
|
||||
/* random number for private key */
|
||||
ret = wc_RNG_GenerateBlock(rng, key->k, keysize);
|
||||
}
|
||||
if (ret == 0) {
|
||||
/* Clamp the private key */
|
||||
key->k[0] &= 0xfc;
|
||||
key->k[CURVE448_KEY_SIZE-1] |= 0x80;
|
||||
|
||||
/* compute public key */
|
||||
ret = curve448(key->p, key->k, basepoint);
|
||||
if (ret != 0) {
|
||||
ForceZero(key->k, keysize);
|
||||
ForceZero(key->p, keysize);
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
#ifdef HAVE_CURVE448_SHARED_SECRET
|
||||
|
||||
/* Calculate the shared secret from the private key and peer's public key.
|
||||
* Calculation over curve448.
|
||||
* Secret encoded big-endian.
|
||||
*
|
||||
* private_key [in] Curve448 private key.
|
||||
* public_key [in] Curve448 public key.
|
||||
* out [in] Array to hold shared secret.
|
||||
* outLen [in/out] On in, the number of bytes in array.
|
||||
* On out, the number bytes put into array.
|
||||
* returns BAD_FUNC_ARG when a parameter is NULL or outLen is less than
|
||||
* CURVE448_KEY_SIZE,
|
||||
* 0 otherwise.
|
||||
*/
|
||||
int wc_curve448_shared_secret(curve448_key* private_key,
|
||||
curve448_key* public_key,
|
||||
byte* out, word32* outLen)
|
||||
{
|
||||
return wc_curve448_shared_secret_ex(private_key, public_key, out, outLen,
|
||||
EC448_BIG_ENDIAN);
|
||||
}
|
||||
|
||||
/* Calculate the shared secret from the private key and peer's public key.
|
||||
* Calculation over curve448.
|
||||
*
|
||||
* private_key [in] Curve448 private key.
|
||||
* public_key [in] Curve448 public key.
|
||||
* out [in] Array to hold shared secret.
|
||||
* outLen [in/out] On in, the number of bytes in array.
|
||||
* On out, the number bytes put into array.
|
||||
* endian [in] Endianness to use when encoding number in array.
|
||||
* returns BAD_FUNC_ARG when a parameter is NULL or outLen is less than
|
||||
* CURVE448_PUB_KEY_SIZE,
|
||||
* 0 otherwise.
|
||||
*/
|
||||
int wc_curve448_shared_secret_ex(curve448_key* private_key,
|
||||
curve448_key* public_key,
|
||||
byte* out, word32* outLen, int endian)
|
||||
{
|
||||
unsigned char o[CURVE448_PUB_KEY_SIZE];
|
||||
int ret = 0;
|
||||
int i;
|
||||
|
||||
/* sanity check */
|
||||
if ((private_key == NULL) || (public_key == NULL) || (out == NULL) ||
|
||||
(outLen == NULL) || (*outLen < CURVE448_PUB_KEY_SIZE)) {
|
||||
ret = BAD_FUNC_ARG;
|
||||
}
|
||||
|
||||
if (ret == 0) {
|
||||
ret = curve448(o, private_key->k, public_key->p);
|
||||
}
|
||||
if (ret == 0) {
|
||||
if (endian == EC448_BIG_ENDIAN) {
|
||||
/* put shared secret key in Big Endian format */
|
||||
for (i = 0; i < CURVE448_PUB_KEY_SIZE; i++) {
|
||||
out[i] = o[CURVE448_PUB_KEY_SIZE - i -1];
|
||||
}
|
||||
}
|
||||
else {
|
||||
/* put shared secret key in Little Endian format */
|
||||
XMEMCPY(out, o, CURVE448_PUB_KEY_SIZE);
|
||||
}
|
||||
|
||||
*outLen = CURVE448_PUB_KEY_SIZE;
|
||||
}
|
||||
|
||||
ForceZero(o, CURVE448_PUB_KEY_SIZE);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
#endif /* HAVE_CURVE448_SHARED_SECRET */
|
||||
|
||||
#ifdef HAVE_CURVE448_KEY_EXPORT
|
||||
|
||||
/* Export the curve448 public key.
|
||||
* Public key encoded big-endian.
|
||||
*
|
||||
* key [in] Curve448 public key.
|
||||
* out [in] Array to hold public key.
|
||||
* outLen [in/out] On in, the number of bytes in array.
|
||||
* On out, the number bytes put into array.
|
||||
* returns BAD_FUNC_ARG when a parameter is NULL,
|
||||
* ECC_BAD_ARG_E when outLen is less than CURVE448_PUB_KEY_SIZE,
|
||||
* 0 otherwise.
|
||||
*/
|
||||
int wc_curve448_export_public(curve448_key* key, byte* out, word32* outLen)
|
||||
{
|
||||
return wc_curve448_export_public_ex(key, out, outLen, EC448_BIG_ENDIAN);
|
||||
}
|
||||
|
||||
/* Export the curve448 public key.
|
||||
*
|
||||
* key [in] Curve448 public key.
|
||||
* out [in] Array to hold public key.
|
||||
* outLen [in/out] On in, the number of bytes in array.
|
||||
* On out, the number bytes put into array.
|
||||
* endian [in] Endianness to use when encoding number in array.
|
||||
* returns BAD_FUNC_ARG when a parameter is NULL,
|
||||
* ECC_BAD_ARG_E when outLen is less than CURVE448_PUB_KEY_SIZE,
|
||||
* 0 otherwise.
|
||||
*/
|
||||
int wc_curve448_export_public_ex(curve448_key* key, byte* out, word32* outLen,
|
||||
int endian)
|
||||
{
|
||||
int ret = 0;
|
||||
int i;
|
||||
|
||||
if ((key == NULL) || (out == NULL) || (outLen == NULL)) {
|
||||
ret = BAD_FUNC_ARG;
|
||||
}
|
||||
|
||||
/* check and set outgoing key size */
|
||||
if ((ret == 0) && (*outLen < CURVE448_PUB_KEY_SIZE)) {
|
||||
*outLen = CURVE448_PUB_KEY_SIZE;
|
||||
ret = ECC_BAD_ARG_E;
|
||||
}
|
||||
if (ret == 0) {
|
||||
*outLen = CURVE448_PUB_KEY_SIZE;
|
||||
|
||||
if (endian == EC448_BIG_ENDIAN) {
|
||||
/* read keys in Big Endian format */
|
||||
for (i = 0; i < CURVE448_PUB_KEY_SIZE; i++) {
|
||||
out[i] = key->p[CURVE448_PUB_KEY_SIZE - i - 1];
|
||||
}
|
||||
}
|
||||
else {
|
||||
XMEMCPY(out, key->p, CURVE448_PUB_KEY_SIZE);
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
#endif /* HAVE_CURVE448_KEY_EXPORT */
|
||||
|
||||
#ifdef HAVE_CURVE448_KEY_IMPORT
|
||||
|
||||
/* Import a curve448 public key from a byte array.
|
||||
* Public key encoded in big-endian.
|
||||
*
|
||||
* in [in] Array holding public key.
|
||||
* inLen [in] Number of bytes of data in array.
|
||||
* key [in] Curve448 public key.
|
||||
* returns BAD_FUNC_ARG when a parameter is NULL,
|
||||
* ECC_BAD_ARG_E when inLen is less than CURVE448_PUB_KEY_SIZE,
|
||||
* 0 otherwise.
|
||||
*/
|
||||
int wc_curve448_import_public(const byte* in, word32 inLen, curve448_key* key)
|
||||
{
|
||||
return wc_curve448_import_public_ex(in, inLen, key, EC448_BIG_ENDIAN);
|
||||
}
|
||||
|
||||
/* Import a curve448 public key from a byte array.
|
||||
*
|
||||
* in [in] Array holding public key.
|
||||
* inLen [in] Number of bytes of data in array.
|
||||
* key [in] Curve448 public key.
|
||||
* endian [in] Endianness of encoded number in byte array.
|
||||
* returns BAD_FUNC_ARG when a parameter is NULL,
|
||||
* ECC_BAD_ARG_E when inLen is less than CURVE448_PUB_KEY_SIZE,
|
||||
* 0 otherwise.
|
||||
*/
|
||||
int wc_curve448_import_public_ex(const byte* in, word32 inLen,
|
||||
curve448_key* key, int endian)
|
||||
{
|
||||
int ret = 0;
|
||||
int i;
|
||||
|
||||
/* sanity check */
|
||||
if ((key == NULL) || (in == NULL)) {
|
||||
ret = BAD_FUNC_ARG;
|
||||
}
|
||||
|
||||
/* check size of incoming keys */
|
||||
if ((ret == 0) && (inLen != CURVE448_PUB_KEY_SIZE)) {
|
||||
ret = ECC_BAD_ARG_E;
|
||||
}
|
||||
|
||||
if (ret == 0) {
|
||||
if (endian == EC448_BIG_ENDIAN) {
|
||||
/* read keys in Big Endian format */
|
||||
for (i = 0; i < CURVE448_PUB_KEY_SIZE; i++) {
|
||||
key->p[i] = in[CURVE448_PUB_KEY_SIZE - i - 1];
|
||||
}
|
||||
}
|
||||
else
|
||||
XMEMCPY(key->p, in, inLen);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* Check the public key value (big or little endian)
|
||||
*
|
||||
* pub [in] Public key bytes.
|
||||
* pubSz [in] Size of public key in bytes.
|
||||
* endian [in] Public key bytes passed in as big-endian or little-endian.
|
||||
* returns BAD_FUNC_ARGS when pub is NULL,
|
||||
* ECC_BAD_ARG_E when key length is not 56 bytes, public key value is
|
||||
* zero or one;
|
||||
* BUFFER_E when size of public key is zero;
|
||||
* 0 otherwise.
|
||||
*/
|
||||
int wc_curve448_check_public(const byte* pub, word32 pubSz, int endian)
|
||||
{
|
||||
int ret = 0;
|
||||
word32 i;
|
||||
|
||||
if (pub == NULL) {
|
||||
ret = BAD_FUNC_ARG;
|
||||
}
|
||||
|
||||
/* Check for empty key data */
|
||||
if ((ret == 0) && (pubSz == 0)) {
|
||||
ret = BUFFER_E;
|
||||
}
|
||||
|
||||
/* Check key length */
|
||||
if ((ret == 0) && (pubSz != CURVE448_PUB_KEY_SIZE)) {
|
||||
ret = ECC_BAD_ARG_E;
|
||||
}
|
||||
|
||||
if (ret == 0) {
|
||||
if (endian == EC448_LITTLE_ENDIAN) {
|
||||
/* Check for value of zero or one */
|
||||
for (i = pubSz - 1; i > 0; i--) {
|
||||
if (pub[i] != 0) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
if ((i == 0) && (pub[0] == 0 || pub[0] == 1)) {
|
||||
return ECC_BAD_ARG_E;
|
||||
}
|
||||
}
|
||||
else {
|
||||
/* Check for value of zero or one */
|
||||
for (i = 0; i < pubSz-1; i++) {
|
||||
if (pub[i] != 0) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
if ((i == pubSz - 1) && (pub[i] == 0 || pub[i] == 1)) {
|
||||
ret = ECC_BAD_ARG_E;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
#endif /* HAVE_CURVE448_KEY_IMPORT */
|
||||
|
||||
|
||||
#ifdef HAVE_CURVE448_KEY_EXPORT
|
||||
|
||||
/* Export the curve448 private key raw form.
|
||||
* Private key encoded big-endian.
|
||||
*
|
||||
* key [in] Curve448 private key.
|
||||
* out [in] Array to hold private key.
|
||||
* outLen [in/out] On in, the number of bytes in array.
|
||||
* On out, the number bytes put into array.
|
||||
* returns BAD_FUNC_ARG when a parameter is NULL,
|
||||
* ECC_BAD_ARG_E when outLen is less than CURVE448_KEY_SIZE,
|
||||
* 0 otherwise.
|
||||
*/
|
||||
int wc_curve448_export_private_raw(curve448_key* key, byte* out, word32* outLen)
|
||||
{
|
||||
return wc_curve448_export_private_raw_ex(key, out, outLen,
|
||||
EC448_BIG_ENDIAN);
|
||||
}
|
||||
|
||||
/* Export the curve448 private key raw form.
|
||||
*
|
||||
* key [in] Curve448 private key.
|
||||
* out [in] Array to hold private key.
|
||||
* outLen [in/out] On in, the number of bytes in array.
|
||||
* On out, the number bytes put into array.
|
||||
* endian [in] Endianness to use when encoding number in array.
|
||||
* returns BAD_FUNC_ARG when a parameter is NULL,
|
||||
* ECC_BAD_ARG_E when outLen is less than CURVE448_KEY_SIZE,
|
||||
* 0 otherwise.
|
||||
*/
|
||||
int wc_curve448_export_private_raw_ex(curve448_key* key, byte* out,
|
||||
word32* outLen, int endian)
|
||||
{
|
||||
int ret = 0;
|
||||
int i;
|
||||
|
||||
/* sanity check */
|
||||
if ((key == NULL) || (out == NULL) || (outLen == NULL)) {
|
||||
ret = BAD_FUNC_ARG;
|
||||
}
|
||||
|
||||
/* check size of outgoing buffer */
|
||||
if ((ret == 0) && (*outLen < CURVE448_KEY_SIZE)) {
|
||||
*outLen = CURVE448_KEY_SIZE;
|
||||
ret = ECC_BAD_ARG_E;
|
||||
}
|
||||
if (ret == 0) {
|
||||
*outLen = CURVE448_KEY_SIZE;
|
||||
|
||||
if (endian == EC448_BIG_ENDIAN) {
|
||||
/* put the key in Big Endian format */
|
||||
for (i = 0; i < CURVE448_KEY_SIZE; i++) {
|
||||
out[i] = key->k[CURVE448_KEY_SIZE - i - 1];
|
||||
}
|
||||
}
|
||||
else {
|
||||
XMEMCPY(out, key->k, CURVE448_KEY_SIZE);
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* Export the curve448 private and public keys in raw form.
|
||||
* Private and public key encoded big-endian.
|
||||
*
|
||||
* key [in] Curve448 private key.
|
||||
* priv [in] Array to hold private key.
|
||||
* privSz [in/out] On in, the number of bytes in private key array.
|
||||
* On out, the number bytes put into private key array.
|
||||
* pub [in] Array to hold public key.
|
||||
* pubSz [in/out] On in, the number of bytes in public key array.
|
||||
* On out, the number bytes put into public key array.
|
||||
* returns BAD_FUNC_ARG when a parameter is NULL,
|
||||
* ECC_BAD_ARG_E when privSz is less than CURVE448_KEY_SIZE or pubSz is
|
||||
* less than CURVE448_PUB_KEY_SIZE,
|
||||
* 0 otherwise.
|
||||
*/
|
||||
int wc_curve448_export_key_raw(curve448_key* key, byte* priv, word32 *privSz,
|
||||
byte* pub, word32 *pubSz)
|
||||
{
|
||||
return wc_curve448_export_key_raw_ex(key, priv, privSz, pub, pubSz,
|
||||
EC448_BIG_ENDIAN);
|
||||
}
|
||||
|
||||
/* Export the curve448 private and public keys in raw form.
|
||||
*
|
||||
* key [in] Curve448 private key.
|
||||
* priv [in] Array to hold private key.
|
||||
* privSz [in/out] On in, the number of bytes in private key array.
|
||||
* On out, the number bytes put into private key array.
|
||||
* pub [in] Array to hold public key.
|
||||
* pubSz [in/out] On in, the number of bytes in public key array.
|
||||
* On out, the number bytes put into public key array.
|
||||
* endian [in] Endianness to use when encoding number in array.
|
||||
* returns BAD_FUNC_ARG when a parameter is NULL,
|
||||
* ECC_BAD_ARG_E when privSz is less than CURVE448_KEY_SIZE or pubSz is
|
||||
* less than CURVE448_PUB_KEY_SIZE,
|
||||
* 0 otherwise.
|
||||
*/
|
||||
int wc_curve448_export_key_raw_ex(curve448_key* key, byte* priv, word32 *privSz,
|
||||
byte* pub, word32 *pubSz, int endian)
|
||||
{
|
||||
int ret;
|
||||
|
||||
/* export private part */
|
||||
ret = wc_curve448_export_private_raw_ex(key, priv, privSz, endian);
|
||||
if (ret == 0) {
|
||||
/* export public part */
|
||||
ret = wc_curve448_export_public_ex(key, pub, pubSz, endian);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
#endif /* HAVE_CURVE448_KEY_EXPORT */
|
||||
|
||||
#ifdef HAVE_CURVE448_KEY_IMPORT
|
||||
|
||||
/* Import curve448 private and public keys from a byte arrays.
|
||||
* Private and public keys encoded in big-endian.
|
||||
*
|
||||
* piv [in] Array holding private key.
|
||||
* privSz [in] Number of bytes of data in private key array.
|
||||
* pub [in] Array holding public key.
|
||||
* pubSz [in] Number of bytes of data in public key array.
|
||||
* key [in] Curve448 private/public key.
|
||||
* returns BAD_FUNC_ARG when a parameter is NULL,
|
||||
* ECC_BAD_ARG_E when privSz is less than CURVE448_KEY_SIZE or pubSz is
|
||||
* less than CURVE448_PUB_KEY_SIZE,
|
||||
* 0 otherwise.
|
||||
*/
|
||||
int wc_curve448_import_private_raw(const byte* priv, word32 privSz,
|
||||
const byte* pub, word32 pubSz,
|
||||
curve448_key* key)
|
||||
{
|
||||
return wc_curve448_import_private_raw_ex(priv, privSz, pub, pubSz, key,
|
||||
EC448_BIG_ENDIAN);
|
||||
}
|
||||
|
||||
/* Import curve448 private and public keys from a byte arrays.
|
||||
*
|
||||
* piv [in] Array holding private key.
|
||||
* privSz [in] Number of bytes of data in private key array.
|
||||
* pub [in] Array holding public key.
|
||||
* pubSz [in] Number of bytes of data in public key array.
|
||||
* key [in] Curve448 private/public key.
|
||||
* endian [in] Endianness of encoded numbers in byte arrays.
|
||||
* returns BAD_FUNC_ARG when a parameter is NULL,
|
||||
* ECC_BAD_ARG_E when privSz is less than CURVE448_KEY_SIZE or pubSz is
|
||||
* less than CURVE448_PUB_KEY_SIZE,
|
||||
* 0 otherwise.
|
||||
*/
|
||||
int wc_curve448_import_private_raw_ex(const byte* priv, word32 privSz,
|
||||
const byte* pub, word32 pubSz,
|
||||
curve448_key* key, int endian)
|
||||
{
|
||||
int ret;
|
||||
|
||||
/* import private part */
|
||||
ret = wc_curve448_import_private_ex(priv, privSz, key, endian);
|
||||
if (ret == 0) {
|
||||
/* import public part */
|
||||
return wc_curve448_import_public_ex(pub, pubSz, key, endian);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* Import curve448 private key from a byte array.
|
||||
* Private key encoded in big-endian.
|
||||
*
|
||||
* piv [in] Array holding private key.
|
||||
* privSz [in] Number of bytes of data in private key array.
|
||||
* key [in] Curve448 private/public key.
|
||||
* returns BAD_FUNC_ARG when a parameter is NULL,
|
||||
* ECC_BAD_ARG_E when privSz is less than CURVE448_KEY_SIZE,
|
||||
* 0 otherwise.
|
||||
*/
|
||||
int wc_curve448_import_private(const byte* priv, word32 privSz,
|
||||
curve448_key* key)
|
||||
{
|
||||
return wc_curve448_import_private_ex(priv, privSz, key, EC448_BIG_ENDIAN);
|
||||
}
|
||||
|
||||
/* Import curve448 private key from a byte array.
|
||||
*
|
||||
* piv [in] Array holding private key.
|
||||
* privSz [in] Number of bytes of data in private key array.
|
||||
* key [in] Curve448 private/public key.
|
||||
* endian [in] Endianness of encoded number in byte array.
|
||||
* returns BAD_FUNC_ARG when a parameter is NULL,
|
||||
* ECC_BAD_ARG_E when privSz is less than CURVE448_KEY_SIZE,
|
||||
* 0 otherwise.
|
||||
*/
|
||||
int wc_curve448_import_private_ex(const byte* priv, word32 privSz,
|
||||
curve448_key* key, int endian)
|
||||
{
|
||||
int ret = 0;
|
||||
int i;
|
||||
|
||||
/* sanity check */
|
||||
if ((key == NULL) || (priv == NULL)) {
|
||||
ret = BAD_FUNC_ARG;
|
||||
}
|
||||
|
||||
/* check size of incoming keys */
|
||||
if ((ret == 0) && ((int)privSz != CURVE448_KEY_SIZE)) {
|
||||
ret = ECC_BAD_ARG_E;
|
||||
}
|
||||
|
||||
if (ret == 0) {
|
||||
if (endian == EC448_BIG_ENDIAN) {
|
||||
/* read the key in Big Endian format */
|
||||
for (i = 0; i < CURVE448_KEY_SIZE; i++) {
|
||||
key->k[i] = priv[CURVE448_KEY_SIZE - i - 1];
|
||||
}
|
||||
}
|
||||
else {
|
||||
XMEMCPY(key->k, priv, CURVE448_KEY_SIZE);
|
||||
}
|
||||
|
||||
/* Clamp the key */
|
||||
key->k[0] &= 0xfc;
|
||||
key->k[CURVE448_KEY_SIZE-1] |= 0x80;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
#endif /* HAVE_CURVE448_KEY_IMPORT */
|
||||
|
||||
|
||||
/* Initialize the curve448 key.
|
||||
*
|
||||
* key [in] Curve448 key object.
|
||||
* returns BAD_FUNC_ARG when key is NULL,
|
||||
* 0 otherwise.
|
||||
*/
|
||||
int wc_curve448_init(curve448_key* key)
|
||||
{
|
||||
int ret = 0;
|
||||
|
||||
if (key == NULL) {
|
||||
ret = BAD_FUNC_ARG;
|
||||
}
|
||||
|
||||
if (ret == 0) {
|
||||
XMEMSET(key, 0, sizeof(*key));
|
||||
|
||||
fe448_init();
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
/* Clears the curve448 key data.
|
||||
*
|
||||
* key [in] Curve448 key object.
|
||||
*/
|
||||
void wc_curve448_free(curve448_key* key)
|
||||
{
|
||||
if (key != NULL) {
|
||||
ForceZero(key->p, sizeof(key->p));
|
||||
ForceZero(key->k, sizeof(key->k));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* Get the curve448 key's size.
|
||||
*
|
||||
* key [in] Curve448 key object.
|
||||
* returns 0 if key is NULL,
|
||||
* CURVE448_KEY_SIZE otherwise.
|
||||
*/
|
||||
int wc_curve448_size(curve448_key* key)
|
||||
{
|
||||
int ret = 0;
|
||||
|
||||
if (key != NULL) {
|
||||
ret = CURVE448_KEY_SIZE;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
#endif /* HAVE_CURVE448 */
|
||||
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -1,920 +0,0 @@
|
||||
/* dsa.c
|
||||
*
|
||||
* Copyright (C) 2006-2020 wolfSSL Inc.
|
||||
*
|
||||
* This file is part of wolfSSL.
|
||||
*
|
||||
* wolfSSL is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* wolfSSL is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA
|
||||
*/
|
||||
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
#endif
|
||||
|
||||
#include <wolfssl/wolfcrypt/settings.h>
|
||||
|
||||
#ifndef NO_DSA
|
||||
|
||||
#include <wolfssl/wolfcrypt/random.h>
|
||||
#include <wolfssl/wolfcrypt/integer.h>
|
||||
#include <wolfssl/wolfcrypt/error-crypt.h>
|
||||
#include <wolfssl/wolfcrypt/logging.h>
|
||||
#include <wolfssl/wolfcrypt/sha.h>
|
||||
#include <wolfssl/wolfcrypt/dsa.h>
|
||||
|
||||
#ifdef NO_INLINE
|
||||
#include <wolfssl/wolfcrypt/misc.h>
|
||||
#else
|
||||
#define WOLFSSL_MISC_INCLUDED
|
||||
#include <wolfcrypt/src/misc.c>
|
||||
#endif
|
||||
|
||||
int wc_InitDsaKey(DsaKey* key)
|
||||
{
|
||||
if (key == NULL)
|
||||
return BAD_FUNC_ARG;
|
||||
|
||||
key->type = -1; /* haven't decided yet */
|
||||
key->heap = NULL;
|
||||
|
||||
return mp_init_multi(
|
||||
/* public alloc parts */
|
||||
&key->p,
|
||||
&key->q,
|
||||
&key->g,
|
||||
&key->y,
|
||||
|
||||
/* private alloc parts */
|
||||
&key->x,
|
||||
NULL
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
int wc_InitDsaKey_h(DsaKey* key, void* h)
|
||||
{
|
||||
int ret = wc_InitDsaKey(key);
|
||||
if (ret == 0)
|
||||
key->heap = h;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
void wc_FreeDsaKey(DsaKey* key)
|
||||
{
|
||||
if (key == NULL)
|
||||
return;
|
||||
|
||||
if (key->type == DSA_PRIVATE)
|
||||
mp_forcezero(&key->x);
|
||||
|
||||
mp_clear(&key->x);
|
||||
mp_clear(&key->y);
|
||||
mp_clear(&key->g);
|
||||
mp_clear(&key->q);
|
||||
mp_clear(&key->p);
|
||||
}
|
||||
|
||||
|
||||
/* validate that (L,N) match allowed sizes from FIPS 186-4, Section 4.2.
|
||||
* modLen - represents L, the size of p (prime modulus) in bits
|
||||
* divLen - represents N, the size of q (prime divisor) in bits
|
||||
* return 0 on success, -1 on error */
|
||||
static int CheckDsaLN(int modLen, int divLen)
|
||||
{
|
||||
int ret = -1;
|
||||
|
||||
switch (modLen) {
|
||||
case 1024:
|
||||
if (divLen == 160)
|
||||
ret = 0;
|
||||
break;
|
||||
case 2048:
|
||||
if (divLen == 224 || divLen == 256)
|
||||
ret = 0;
|
||||
break;
|
||||
case 3072:
|
||||
if (divLen == 256)
|
||||
ret = 0;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
#ifdef WOLFSSL_KEY_GEN
|
||||
|
||||
/* Create DSA key pair (&dsa->x, &dsa->y)
|
||||
*
|
||||
* Based on NIST FIPS 186-4,
|
||||
* "B.1.1 Key Pair Generation Using Extra Random Bits"
|
||||
*
|
||||
* rng - pointer to initialized WC_RNG structure
|
||||
* dsa - pointer to initialized DsaKey structure, will hold generated key
|
||||
*
|
||||
* return 0 on success, negative on error */
|
||||
int wc_MakeDsaKey(WC_RNG *rng, DsaKey *dsa)
|
||||
{
|
||||
byte* cBuf;
|
||||
int qSz, pSz, cSz, err;
|
||||
mp_int tmpQ;
|
||||
|
||||
if (rng == NULL || dsa == NULL)
|
||||
return BAD_FUNC_ARG;
|
||||
|
||||
qSz = mp_unsigned_bin_size(&dsa->q);
|
||||
pSz = mp_unsigned_bin_size(&dsa->p);
|
||||
|
||||
/* verify (L,N) pair bit lengths */
|
||||
if (CheckDsaLN(pSz * WOLFSSL_BIT_SIZE, qSz * WOLFSSL_BIT_SIZE) != 0)
|
||||
return BAD_FUNC_ARG;
|
||||
|
||||
/* generate extra 64 bits so that bias from mod function is negligible */
|
||||
cSz = qSz + (64 / WOLFSSL_BIT_SIZE);
|
||||
cBuf = (byte*)XMALLOC(cSz, dsa->heap, DYNAMIC_TYPE_TMP_BUFFER);
|
||||
if (cBuf == NULL) {
|
||||
return MEMORY_E;
|
||||
}
|
||||
|
||||
if ((err = mp_init_multi(&dsa->x, &dsa->y, &tmpQ, NULL, NULL, NULL))
|
||||
!= MP_OKAY) {
|
||||
XFREE(cBuf, dsa->heap, DYNAMIC_TYPE_TMP_BUFFER);
|
||||
return err;
|
||||
}
|
||||
|
||||
do {
|
||||
/* generate N+64 bits (c) from RBG into &dsa->x, making sure positive.
|
||||
* Hash_DRBG uses SHA-256 which matches maximum
|
||||
* requested_security_strength of (L,N) */
|
||||
err = wc_RNG_GenerateBlock(rng, cBuf, cSz);
|
||||
if (err != MP_OKAY) {
|
||||
mp_clear(&dsa->x);
|
||||
mp_clear(&dsa->y);
|
||||
mp_clear(&tmpQ);
|
||||
XFREE(cBuf, dsa->heap, DYNAMIC_TYPE_TMP_BUFFER);
|
||||
return err;
|
||||
}
|
||||
|
||||
err = mp_read_unsigned_bin(&dsa->x, cBuf, cSz);
|
||||
if (err != MP_OKAY) {
|
||||
mp_clear(&dsa->x);
|
||||
mp_clear(&dsa->y);
|
||||
mp_clear(&tmpQ);
|
||||
XFREE(cBuf, dsa->heap, DYNAMIC_TYPE_TMP_BUFFER);
|
||||
return err;
|
||||
}
|
||||
} while (mp_cmp_d(&dsa->x, 1) != MP_GT);
|
||||
|
||||
XFREE(cBuf, dsa->heap, DYNAMIC_TYPE_TMP_BUFFER);
|
||||
|
||||
/* tmpQ = q - 1 */
|
||||
if (err == MP_OKAY)
|
||||
err = mp_copy(&dsa->q, &tmpQ);
|
||||
|
||||
if (err == MP_OKAY)
|
||||
err = mp_sub_d(&tmpQ, 1, &tmpQ);
|
||||
|
||||
/* x = c mod (q-1), &dsa->x holds c */
|
||||
if (err == MP_OKAY)
|
||||
err = mp_mod(&dsa->x, &tmpQ, &dsa->x);
|
||||
|
||||
/* x = c mod (q-1) + 1 */
|
||||
if (err == MP_OKAY)
|
||||
err = mp_add_d(&dsa->x, 1, &dsa->x);
|
||||
|
||||
/* public key : y = g^x mod p */
|
||||
if (err == MP_OKAY)
|
||||
err = mp_exptmod_ex(&dsa->g, &dsa->x, dsa->q.used, &dsa->p, &dsa->y);
|
||||
|
||||
if (err == MP_OKAY)
|
||||
dsa->type = DSA_PRIVATE;
|
||||
|
||||
if (err != MP_OKAY) {
|
||||
mp_clear(&dsa->x);
|
||||
mp_clear(&dsa->y);
|
||||
}
|
||||
mp_clear(&tmpQ);
|
||||
|
||||
return err;
|
||||
}
|
||||
|
||||
|
||||
/* modulus_size in bits */
|
||||
int wc_MakeDsaParameters(WC_RNG *rng, int modulus_size, DsaKey *dsa)
|
||||
{
|
||||
mp_int tmp, tmp2;
|
||||
int err, msize, qsize,
|
||||
loop_check_prime = 0,
|
||||
check_prime = MP_NO;
|
||||
unsigned char *buf;
|
||||
|
||||
if (rng == NULL || dsa == NULL)
|
||||
return BAD_FUNC_ARG;
|
||||
|
||||
/* set group size in bytes from modulus size
|
||||
* FIPS 186-4 defines valid values (1024, 160) (2048, 256) (3072, 256)
|
||||
*/
|
||||
switch (modulus_size) {
|
||||
case 1024:
|
||||
qsize = 20;
|
||||
break;
|
||||
case 2048:
|
||||
case 3072:
|
||||
qsize = 32;
|
||||
break;
|
||||
default:
|
||||
return BAD_FUNC_ARG;
|
||||
}
|
||||
|
||||
/* modulus size in bytes */
|
||||
msize = modulus_size / WOLFSSL_BIT_SIZE;
|
||||
|
||||
/* allocate ram */
|
||||
buf = (unsigned char *)XMALLOC(msize - qsize,
|
||||
dsa->heap, DYNAMIC_TYPE_TMP_BUFFER);
|
||||
if (buf == NULL) {
|
||||
return MEMORY_E;
|
||||
}
|
||||
|
||||
/* make a random string that will be multiplied against q */
|
||||
err = wc_RNG_GenerateBlock(rng, buf, msize - qsize);
|
||||
if (err != MP_OKAY) {
|
||||
XFREE(buf, dsa->heap, DYNAMIC_TYPE_TMP_BUFFER);
|
||||
return err;
|
||||
}
|
||||
|
||||
/* force magnitude */
|
||||
buf[0] |= 0xC0;
|
||||
|
||||
/* force even */
|
||||
buf[msize - qsize - 1] &= ~1;
|
||||
|
||||
if (mp_init_multi(&tmp2, &dsa->p, &dsa->q, 0, 0, 0) != MP_OKAY) {
|
||||
mp_clear(&dsa->q);
|
||||
XFREE(buf, dsa->heap, DYNAMIC_TYPE_TMP_BUFFER);
|
||||
return MP_INIT_E;
|
||||
}
|
||||
|
||||
err = mp_read_unsigned_bin(&tmp2, buf, msize - qsize);
|
||||
if (err != MP_OKAY) {
|
||||
mp_clear(&dsa->q);
|
||||
mp_clear(&dsa->p);
|
||||
mp_clear(&tmp2);
|
||||
XFREE(buf, dsa->heap, DYNAMIC_TYPE_TMP_BUFFER);
|
||||
return err;
|
||||
}
|
||||
XFREE(buf, dsa->heap, DYNAMIC_TYPE_TMP_BUFFER);
|
||||
|
||||
/* make our prime q */
|
||||
err = mp_rand_prime(&dsa->q, qsize, rng, NULL);
|
||||
if (err != MP_OKAY) {
|
||||
mp_clear(&dsa->q);
|
||||
mp_clear(&dsa->p);
|
||||
mp_clear(&tmp2);
|
||||
return err;
|
||||
}
|
||||
|
||||
/* p = random * q */
|
||||
err = mp_mul(&dsa->q, &tmp2, &dsa->p);
|
||||
if (err != MP_OKAY) {
|
||||
mp_clear(&dsa->q);
|
||||
mp_clear(&dsa->p);
|
||||
mp_clear(&tmp2);
|
||||
return err;
|
||||
}
|
||||
|
||||
/* p = random * q + 1, so q is a prime divisor of p-1 */
|
||||
err = mp_add_d(&dsa->p, 1, &dsa->p);
|
||||
if (err != MP_OKAY) {
|
||||
mp_clear(&dsa->q);
|
||||
mp_clear(&dsa->p);
|
||||
mp_clear(&tmp2);
|
||||
return err;
|
||||
}
|
||||
|
||||
if (mp_init(&tmp) != MP_OKAY) {
|
||||
mp_clear(&dsa->q);
|
||||
mp_clear(&dsa->p);
|
||||
mp_clear(&tmp2);
|
||||
return MP_INIT_E;
|
||||
}
|
||||
|
||||
/* tmp = 2q */
|
||||
err = mp_add(&dsa->q, &dsa->q, &tmp);
|
||||
if (err != MP_OKAY) {
|
||||
mp_clear(&dsa->q);
|
||||
mp_clear(&dsa->p);
|
||||
mp_clear(&tmp);
|
||||
mp_clear(&tmp2);
|
||||
return err;
|
||||
}
|
||||
|
||||
/* loop until p is prime */
|
||||
while (check_prime == MP_NO) {
|
||||
err = mp_prime_is_prime_ex(&dsa->p, 8, &check_prime, rng);
|
||||
if (err != MP_OKAY) {
|
||||
mp_clear(&dsa->q);
|
||||
mp_clear(&dsa->p);
|
||||
mp_clear(&tmp);
|
||||
mp_clear(&tmp2);
|
||||
return err;
|
||||
}
|
||||
|
||||
if (check_prime != MP_YES) {
|
||||
/* p += 2q */
|
||||
err = mp_add(&tmp, &dsa->p, &dsa->p);
|
||||
if (err != MP_OKAY) {
|
||||
mp_clear(&dsa->q);
|
||||
mp_clear(&dsa->p);
|
||||
mp_clear(&tmp);
|
||||
mp_clear(&tmp2);
|
||||
return err;
|
||||
}
|
||||
|
||||
loop_check_prime++;
|
||||
}
|
||||
}
|
||||
|
||||
/* tmp2 += (2*loop_check_prime)
|
||||
* to have p = (q * tmp2) + 1 prime
|
||||
*/
|
||||
if (loop_check_prime) {
|
||||
err = mp_add_d(&tmp2, 2*loop_check_prime, &tmp2);
|
||||
if (err != MP_OKAY) {
|
||||
mp_clear(&dsa->q);
|
||||
mp_clear(&dsa->p);
|
||||
mp_clear(&tmp);
|
||||
mp_clear(&tmp2);
|
||||
return err;
|
||||
}
|
||||
}
|
||||
|
||||
if (mp_init(&dsa->g) != MP_OKAY) {
|
||||
mp_clear(&dsa->q);
|
||||
mp_clear(&dsa->p);
|
||||
mp_clear(&tmp);
|
||||
mp_clear(&tmp2);
|
||||
return MP_INIT_E;
|
||||
}
|
||||
|
||||
/* find a value g for which g^tmp2 != 1 */
|
||||
if (mp_set(&dsa->g, 1) != MP_OKAY) {
|
||||
mp_clear(&dsa->q);
|
||||
mp_clear(&dsa->p);
|
||||
mp_clear(&tmp);
|
||||
mp_clear(&tmp2);
|
||||
return MP_INIT_E;
|
||||
}
|
||||
|
||||
do {
|
||||
err = mp_add_d(&dsa->g, 1, &dsa->g);
|
||||
if (err != MP_OKAY) {
|
||||
mp_clear(&dsa->q);
|
||||
mp_clear(&dsa->p);
|
||||
mp_clear(&dsa->g);
|
||||
mp_clear(&tmp);
|
||||
mp_clear(&tmp2);
|
||||
return err;
|
||||
}
|
||||
|
||||
err = mp_exptmod(&dsa->g, &tmp2, &dsa->p, &tmp);
|
||||
if (err != MP_OKAY) {
|
||||
mp_clear(&dsa->q);
|
||||
mp_clear(&dsa->p);
|
||||
mp_clear(&dsa->g);
|
||||
mp_clear(&tmp);
|
||||
mp_clear(&tmp2);
|
||||
return err;
|
||||
}
|
||||
|
||||
} while (mp_cmp_d(&tmp, 1) == MP_EQ);
|
||||
|
||||
/* at this point tmp generates a group of order q mod p */
|
||||
mp_exch(&tmp, &dsa->g);
|
||||
|
||||
mp_clear(&tmp);
|
||||
mp_clear(&tmp2);
|
||||
|
||||
return MP_OKAY;
|
||||
}
|
||||
#endif /* WOLFSSL_KEY_GEN */
|
||||
|
||||
|
||||
static int _DsaImportParamsRaw(DsaKey* dsa, const char* p, const char* q,
|
||||
const char* g, int trusted, WC_RNG* rng)
|
||||
{
|
||||
int err;
|
||||
word32 pSz, qSz;
|
||||
|
||||
if (dsa == NULL || p == NULL || q == NULL || g == NULL)
|
||||
return BAD_FUNC_ARG;
|
||||
|
||||
/* read p */
|
||||
err = mp_read_radix(&dsa->p, p, MP_RADIX_HEX);
|
||||
if (err == MP_OKAY && !trusted) {
|
||||
int isPrime = 1;
|
||||
if (rng == NULL)
|
||||
err = mp_prime_is_prime(&dsa->p, 8, &isPrime);
|
||||
else
|
||||
err = mp_prime_is_prime_ex(&dsa->p, 8, &isPrime, rng);
|
||||
|
||||
if (err == MP_OKAY) {
|
||||
if (!isPrime)
|
||||
err = DH_CHECK_PUB_E;
|
||||
}
|
||||
}
|
||||
|
||||
/* read q */
|
||||
if (err == MP_OKAY)
|
||||
err = mp_read_radix(&dsa->q, q, MP_RADIX_HEX);
|
||||
|
||||
/* read g */
|
||||
if (err == MP_OKAY)
|
||||
err = mp_read_radix(&dsa->g, g, MP_RADIX_HEX);
|
||||
|
||||
/* verify (L,N) pair bit lengths */
|
||||
pSz = mp_unsigned_bin_size(&dsa->p);
|
||||
qSz = mp_unsigned_bin_size(&dsa->q);
|
||||
|
||||
if (CheckDsaLN(pSz * WOLFSSL_BIT_SIZE, qSz * WOLFSSL_BIT_SIZE) != 0) {
|
||||
WOLFSSL_MSG("Invalid DSA p or q parameter size");
|
||||
err = BAD_FUNC_ARG;
|
||||
}
|
||||
|
||||
if (err != MP_OKAY) {
|
||||
mp_clear(&dsa->p);
|
||||
mp_clear(&dsa->q);
|
||||
mp_clear(&dsa->g);
|
||||
}
|
||||
|
||||
return err;
|
||||
}
|
||||
|
||||
|
||||
/* Import raw DSA parameters into DsaKey structure for use with wc_MakeDsaKey(),
|
||||
* input parameters (p,q,g) should be represented as ASCII hex values.
|
||||
*
|
||||
* dsa - pointer to initialized DsaKey structure
|
||||
* p - DSA (p) parameter, ASCII hex string
|
||||
* pSz - length of p
|
||||
* q - DSA (q) parameter, ASCII hex string
|
||||
* qSz - length of q
|
||||
* g - DSA (g) parameter, ASCII hex string
|
||||
* gSz - length of g
|
||||
*
|
||||
* returns 0 on success, negative upon failure
|
||||
*/
|
||||
int wc_DsaImportParamsRaw(DsaKey* dsa, const char* p, const char* q,
|
||||
const char* g)
|
||||
{
|
||||
return _DsaImportParamsRaw(dsa, p, q, g, 1, NULL);
|
||||
}
|
||||
|
||||
|
||||
/* Import raw DSA parameters into DsaKey structure for use with wc_MakeDsaKey(),
|
||||
* input parameters (p,q,g) should be represented as ASCII hex values. Check
|
||||
* that the p value is probably prime.
|
||||
*
|
||||
* dsa - pointer to initialized DsaKey structure
|
||||
* p - DSA (p) parameter, ASCII hex string
|
||||
* pSz - length of p
|
||||
* q - DSA (q) parameter, ASCII hex string
|
||||
* qSz - length of q
|
||||
* g - DSA (g) parameter, ASCII hex string
|
||||
* gSz - length of g
|
||||
* trusted - trust that p is OK
|
||||
* rng - random number generator for the prime test
|
||||
*
|
||||
* returns 0 on success, negative upon failure
|
||||
*/
|
||||
int wc_DsaImportParamsRawCheck(DsaKey* dsa, const char* p, const char* q,
|
||||
const char* g, int trusted, WC_RNG* rng)
|
||||
{
|
||||
return _DsaImportParamsRaw(dsa, p, q, g, trusted, rng);
|
||||
}
|
||||
|
||||
|
||||
/* Export raw DSA parameters from DsaKey structure
|
||||
*
|
||||
* dsa - pointer to initialized DsaKey structure
|
||||
* p - output location for DSA (p) parameter
|
||||
* pSz - [IN/OUT] size of output buffer for p, size of p
|
||||
* q - output location for DSA (q) parameter
|
||||
* qSz - [IN/OUT] size of output buffer for q, size of q
|
||||
* g - output location for DSA (g) parameter
|
||||
* gSz - [IN/OUT] size of output buffer for g, size of g
|
||||
*
|
||||
* If p, q, and g pointers are all passed in as NULL, the function
|
||||
* will set pSz, qSz, and gSz to the required output buffer sizes for p,
|
||||
* q, and g. In this case, the function will return LENGTH_ONLY_E.
|
||||
*
|
||||
* returns 0 on success, negative upon failure
|
||||
*/
|
||||
int wc_DsaExportParamsRaw(DsaKey* dsa, byte* p, word32* pSz,
|
||||
byte* q, word32* qSz, byte* g, word32* gSz)
|
||||
{
|
||||
int err;
|
||||
word32 pLen, qLen, gLen;
|
||||
|
||||
if (dsa == NULL || pSz == NULL || qSz == NULL || gSz == NULL)
|
||||
return BAD_FUNC_ARG;
|
||||
|
||||
/* get required output buffer sizes */
|
||||
pLen = mp_unsigned_bin_size(&dsa->p);
|
||||
qLen = mp_unsigned_bin_size(&dsa->q);
|
||||
gLen = mp_unsigned_bin_size(&dsa->g);
|
||||
|
||||
/* return buffer sizes and LENGTH_ONLY_E if buffers are NULL */
|
||||
if (p == NULL && q == NULL && g == NULL) {
|
||||
*pSz = pLen;
|
||||
*qSz = qLen;
|
||||
*gSz = gLen;
|
||||
return LENGTH_ONLY_E;
|
||||
}
|
||||
|
||||
if (p == NULL || q == NULL || g == NULL)
|
||||
return BAD_FUNC_ARG;
|
||||
|
||||
/* export p */
|
||||
if (*pSz < pLen) {
|
||||
WOLFSSL_MSG("Output buffer for DSA p parameter too small, "
|
||||
"required size placed into pSz");
|
||||
*pSz = pLen;
|
||||
return BUFFER_E;
|
||||
}
|
||||
*pSz = pLen;
|
||||
err = mp_to_unsigned_bin(&dsa->p, p);
|
||||
|
||||
/* export q */
|
||||
if (err == MP_OKAY) {
|
||||
if (*qSz < qLen) {
|
||||
WOLFSSL_MSG("Output buffer for DSA q parameter too small, "
|
||||
"required size placed into qSz");
|
||||
*qSz = qLen;
|
||||
return BUFFER_E;
|
||||
}
|
||||
*qSz = qLen;
|
||||
err = mp_to_unsigned_bin(&dsa->q, q);
|
||||
}
|
||||
|
||||
/* export g */
|
||||
if (err == MP_OKAY) {
|
||||
if (*gSz < gLen) {
|
||||
WOLFSSL_MSG("Output buffer for DSA g parameter too small, "
|
||||
"required size placed into gSz");
|
||||
*gSz = gLen;
|
||||
return BUFFER_E;
|
||||
}
|
||||
*gSz = gLen;
|
||||
err = mp_to_unsigned_bin(&dsa->g, g);
|
||||
}
|
||||
|
||||
return err;
|
||||
}
|
||||
|
||||
|
||||
/* Export raw DSA key (x, y) from DsaKey structure
|
||||
*
|
||||
* dsa - pointer to initialized DsaKey structure
|
||||
* x - output location for private key
|
||||
* xSz - [IN/OUT] size of output buffer for x, size of x
|
||||
* y - output location for public key
|
||||
* ySz - [IN/OUT] size of output buffer for y, size of y
|
||||
*
|
||||
* If x and y pointers are all passed in as NULL, the function
|
||||
* will set xSz and ySz to the required output buffer sizes for x
|
||||
* and y. In this case, the function will return LENGTH_ONLY_E.
|
||||
*
|
||||
* returns 0 on success, negative upon failure
|
||||
*/
|
||||
int wc_DsaExportKeyRaw(DsaKey* dsa, byte* x, word32* xSz, byte* y, word32* ySz)
|
||||
{
|
||||
int err;
|
||||
word32 xLen, yLen;
|
||||
|
||||
if (dsa == NULL || xSz == NULL || ySz == NULL)
|
||||
return BAD_FUNC_ARG;
|
||||
|
||||
/* get required output buffer sizes */
|
||||
xLen = mp_unsigned_bin_size(&dsa->x);
|
||||
yLen = mp_unsigned_bin_size(&dsa->y);
|
||||
|
||||
/* return buffer sizes and LENGTH_ONLY_E if buffers are NULL */
|
||||
if (x == NULL && y == NULL) {
|
||||
*xSz = xLen;
|
||||
*ySz = yLen;
|
||||
return LENGTH_ONLY_E;
|
||||
}
|
||||
|
||||
if (x == NULL || y == NULL)
|
||||
return BAD_FUNC_ARG;
|
||||
|
||||
/* export x */
|
||||
if (*xSz < xLen) {
|
||||
WOLFSSL_MSG("Output buffer for DSA private key (x) too small, "
|
||||
"required size placed into xSz");
|
||||
*xSz = xLen;
|
||||
return BUFFER_E;
|
||||
}
|
||||
*xSz = xLen;
|
||||
err = mp_to_unsigned_bin(&dsa->x, x);
|
||||
|
||||
/* export y */
|
||||
if (err == MP_OKAY) {
|
||||
if (*ySz < yLen) {
|
||||
WOLFSSL_MSG("Output buffer to DSA public key (y) too small, "
|
||||
"required size placed into ySz");
|
||||
*ySz = yLen;
|
||||
return BUFFER_E;
|
||||
}
|
||||
*ySz = yLen;
|
||||
err = mp_to_unsigned_bin(&dsa->y, y);
|
||||
}
|
||||
|
||||
return err;
|
||||
}
|
||||
|
||||
|
||||
int wc_DsaSign(const byte* digest, byte* out, DsaKey* key, WC_RNG* rng)
|
||||
{
|
||||
mp_int k, kInv, r, s, H;
|
||||
#ifndef WOLFSSL_MP_INVMOD_CONSTANT_TIME
|
||||
mp_int b;
|
||||
#endif
|
||||
mp_int* qMinus1;
|
||||
int ret = 0, sz;
|
||||
byte buffer[DSA_HALF_SIZE];
|
||||
byte* tmp; /* initial output pointer */
|
||||
|
||||
if (digest == NULL || out == NULL || key == NULL || rng == NULL) {
|
||||
return BAD_FUNC_ARG;
|
||||
}
|
||||
|
||||
tmp = out;
|
||||
|
||||
sz = min((int)sizeof(buffer), mp_unsigned_bin_size(&key->q));
|
||||
|
||||
#ifdef WOLFSSL_MP_INVMOD_CONSTANT_TIME
|
||||
if (mp_init_multi(&k, &kInv, &r, &s, &H, 0) != MP_OKAY)
|
||||
#else
|
||||
if (mp_init_multi(&k, &kInv, &r, &s, &H, &b) != MP_OKAY)
|
||||
#endif
|
||||
{
|
||||
return MP_INIT_E;
|
||||
}
|
||||
qMinus1 = &kInv;
|
||||
|
||||
/* NIST FIPS 186-4: B.2.2
|
||||
* Per-Message Secret Number Generation by Testing Candidates
|
||||
* Generate k in range [1, q-1].
|
||||
* Check that k is less than q-1: range [0, q-2].
|
||||
* Add 1 to k: range [1, q-1].
|
||||
*/
|
||||
if (mp_sub_d(&key->q, 1, qMinus1))
|
||||
ret = MP_SUB_E;
|
||||
|
||||
if (ret == 0) {
|
||||
do {
|
||||
/* Step 4: generate k */
|
||||
ret = wc_RNG_GenerateBlock(rng, buffer, sz);
|
||||
|
||||
/* Step 5 */
|
||||
if (ret == 0 && mp_read_unsigned_bin(&k, buffer, sz) != MP_OKAY)
|
||||
ret = MP_READ_E;
|
||||
|
||||
/* k is a random numnber and it should be less than q-1
|
||||
* if k greater than repeat
|
||||
*/
|
||||
/* Step 6 */
|
||||
} while (ret == 0 && mp_cmp(&k, qMinus1) != MP_LT);
|
||||
}
|
||||
/* Step 7 */
|
||||
if (ret == 0 && mp_add_d(&k, 1, &k) != MP_OKAY)
|
||||
ret = MP_MOD_E;
|
||||
|
||||
#ifdef WOLFSSL_MP_INVMOD_CONSTANT_TIME
|
||||
/* inverse k mod q */
|
||||
if (ret == 0 && mp_invmod(&k, &key->q, &kInv) != MP_OKAY)
|
||||
ret = MP_INVMOD_E;
|
||||
|
||||
/* generate r, r = (g exp k mod p) mod q */
|
||||
if (ret == 0 && mp_exptmod_ex(&key->g, &k, key->q.used, &key->p,
|
||||
&r) != MP_OKAY) {
|
||||
ret = MP_EXPTMOD_E;
|
||||
}
|
||||
|
||||
if (ret == 0 && mp_mod(&r, &key->q, &r) != MP_OKAY)
|
||||
ret = MP_MOD_E;
|
||||
|
||||
/* generate H from sha digest */
|
||||
if (ret == 0 && mp_read_unsigned_bin(&H, digest,WC_SHA_DIGEST_SIZE) != MP_OKAY)
|
||||
ret = MP_READ_E;
|
||||
|
||||
/* generate s, s = (kInv * (H + x*r)) % q */
|
||||
if (ret == 0 && mp_mul(&key->x, &r, &s) != MP_OKAY)
|
||||
ret = MP_MUL_E;
|
||||
|
||||
if (ret == 0 && mp_add(&s, &H, &s) != MP_OKAY)
|
||||
ret = MP_ADD_E;
|
||||
|
||||
if (ret == 0 && mp_mulmod(&s, &kInv, &key->q, &s) != MP_OKAY)
|
||||
ret = MP_MULMOD_E;
|
||||
#else
|
||||
/* Blinding value
|
||||
* Generate b in range [1, q-1].
|
||||
*/
|
||||
if (ret == 0) {
|
||||
do {
|
||||
ret = wc_RNG_GenerateBlock(rng, buffer, sz);
|
||||
if (ret == 0 && mp_read_unsigned_bin(&b, buffer, sz) != MP_OKAY)
|
||||
ret = MP_READ_E;
|
||||
} while (ret == 0 && mp_cmp(&b, qMinus1) != MP_LT);
|
||||
}
|
||||
if (ret == 0 && mp_add_d(&b, 1, &b) != MP_OKAY)
|
||||
ret = MP_MOD_E;
|
||||
|
||||
/* set H from sha digest */
|
||||
if (ret == 0 && mp_read_unsigned_bin(&H, digest,
|
||||
WC_SHA_DIGEST_SIZE) != MP_OKAY) {
|
||||
ret = MP_READ_E;
|
||||
}
|
||||
|
||||
/* generate r, r = (g exp k mod p) mod q */
|
||||
if (ret == 0 && mp_exptmod_ex(&key->g, &k, key->q.used, &key->p,
|
||||
&r) != MP_OKAY) {
|
||||
ret = MP_EXPTMOD_E;
|
||||
}
|
||||
|
||||
/* calculate s = (H + xr)/k
|
||||
= b.(H/k.b + x.r/k.b) */
|
||||
|
||||
/* k = k.b */
|
||||
if (ret == 0 && mp_mulmod(&k, &b, &key->q, &k) != MP_OKAY)
|
||||
ret = MP_MULMOD_E;
|
||||
|
||||
/* kInv = 1/k.b mod q */
|
||||
if (ret == 0 && mp_invmod(&k, &key->q, &kInv) != MP_OKAY)
|
||||
ret = MP_INVMOD_E;
|
||||
|
||||
if (ret == 0 && mp_mod(&r, &key->q, &r) != MP_OKAY)
|
||||
ret = MP_MOD_E;
|
||||
|
||||
/* s = x.r */
|
||||
if (ret == 0 && mp_mul(&key->x, &r, &s) != MP_OKAY)
|
||||
ret = MP_MUL_E;
|
||||
|
||||
/* s = x.r/k.b */
|
||||
if (ret == 0 && mp_mulmod(&s, &kInv, &key->q, &s) != MP_OKAY)
|
||||
ret = MP_MULMOD_E;
|
||||
|
||||
/* H = H/k.b */
|
||||
if (ret == 0 && mp_mulmod(&H, &kInv, &key->q, &H) != MP_OKAY)
|
||||
ret = MP_MULMOD_E;
|
||||
|
||||
/* s = H/k.b + x.r/k.b
|
||||
= (H + x.r)/k.b */
|
||||
if (ret == 0 && mp_add(&s, &H, &s) != MP_OKAY)
|
||||
ret = MP_ADD_E;
|
||||
|
||||
/* s = b.(e + x.r)/k.b
|
||||
= (e + x.r)/k */
|
||||
if (ret == 0 && mp_mulmod(&s, &b, &key->q, &s) != MP_OKAY)
|
||||
ret = MP_MULMOD_E;
|
||||
|
||||
/* s = (e + x.r)/k */
|
||||
if (ret == 0 && mp_mod(&s, &key->q, &s) != MP_OKAY)
|
||||
ret = MP_MOD_E;
|
||||
#endif
|
||||
|
||||
/* detect zero r or s */
|
||||
if (ret == 0 && (mp_iszero(&r) == MP_YES || mp_iszero(&s) == MP_YES))
|
||||
ret = MP_ZERO_E;
|
||||
|
||||
/* write out */
|
||||
if (ret == 0) {
|
||||
int rSz = mp_unsigned_bin_size(&r);
|
||||
int sSz = mp_unsigned_bin_size(&s);
|
||||
|
||||
while (rSz++ < DSA_HALF_SIZE) {
|
||||
*out++ = 0x00; /* pad front with zeros */
|
||||
}
|
||||
|
||||
if (mp_to_unsigned_bin(&r, out) != MP_OKAY)
|
||||
ret = MP_TO_E;
|
||||
else {
|
||||
out = tmp + DSA_HALF_SIZE; /* advance to s in output */
|
||||
while (sSz++ < DSA_HALF_SIZE) {
|
||||
*out++ = 0x00; /* pad front with zeros */
|
||||
}
|
||||
ret = mp_to_unsigned_bin(&s, out);
|
||||
}
|
||||
}
|
||||
|
||||
ForceZero(buffer, sz);
|
||||
mp_forcezero(&kInv);
|
||||
mp_forcezero(&k);
|
||||
#ifndef WOLFSSL_MP_INVMOD_CONSTANT_TIME
|
||||
mp_forcezero(&b);
|
||||
|
||||
mp_clear(&b);
|
||||
#endif
|
||||
mp_clear(&H);
|
||||
mp_clear(&s);
|
||||
mp_clear(&r);
|
||||
mp_clear(&kInv);
|
||||
mp_clear(&k);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
int wc_DsaVerify(const byte* digest, const byte* sig, DsaKey* key, int* answer)
|
||||
{
|
||||
mp_int w, u1, u2, v, r, s;
|
||||
int ret = 0;
|
||||
|
||||
if (digest == NULL || sig == NULL || key == NULL || answer == NULL) {
|
||||
return BAD_FUNC_ARG;
|
||||
}
|
||||
|
||||
if (mp_init_multi(&w, &u1, &u2, &v, &r, &s) != MP_OKAY)
|
||||
return MP_INIT_E;
|
||||
|
||||
/* set r and s from signature */
|
||||
if (mp_read_unsigned_bin(&r, sig, DSA_HALF_SIZE) != MP_OKAY ||
|
||||
mp_read_unsigned_bin(&s, sig + DSA_HALF_SIZE, DSA_HALF_SIZE) != MP_OKAY)
|
||||
ret = MP_READ_E;
|
||||
|
||||
/* sanity checks */
|
||||
if (ret == 0) {
|
||||
if (mp_iszero(&r) == MP_YES || mp_iszero(&s) == MP_YES ||
|
||||
mp_cmp(&r, &key->q) != MP_LT || mp_cmp(&s, &key->q) != MP_LT) {
|
||||
ret = MP_ZERO_E;
|
||||
}
|
||||
}
|
||||
|
||||
/* put H into u1 from sha digest */
|
||||
if (ret == 0 && mp_read_unsigned_bin(&u1,digest,WC_SHA_DIGEST_SIZE) != MP_OKAY)
|
||||
ret = MP_READ_E;
|
||||
|
||||
/* w = s invmod q */
|
||||
if (ret == 0 && mp_invmod(&s, &key->q, &w) != MP_OKAY)
|
||||
ret = MP_INVMOD_E;
|
||||
|
||||
/* u1 = (H * w) % q */
|
||||
if (ret == 0 && mp_mulmod(&u1, &w, &key->q, &u1) != MP_OKAY)
|
||||
ret = MP_MULMOD_E;
|
||||
|
||||
/* u2 = (r * w) % q */
|
||||
if (ret == 0 && mp_mulmod(&r, &w, &key->q, &u2) != MP_OKAY)
|
||||
ret = MP_MULMOD_E;
|
||||
|
||||
/* verify v = ((g^u1 * y^u2) mod p) mod q */
|
||||
if (ret == 0 && mp_exptmod(&key->g, &u1, &key->p, &u1) != MP_OKAY)
|
||||
ret = MP_EXPTMOD_E;
|
||||
|
||||
if (ret == 0 && mp_exptmod(&key->y, &u2, &key->p, &u2) != MP_OKAY)
|
||||
ret = MP_EXPTMOD_E;
|
||||
|
||||
if (ret == 0 && mp_mulmod(&u1, &u2, &key->p, &v) != MP_OKAY)
|
||||
ret = MP_MULMOD_E;
|
||||
|
||||
if (ret == 0 && mp_mod(&v, &key->q, &v) != MP_OKAY)
|
||||
ret = MP_MULMOD_E;
|
||||
|
||||
/* do they match */
|
||||
if (ret == 0 && mp_cmp(&r, &v) == MP_EQ)
|
||||
*answer = 1;
|
||||
else
|
||||
*answer = 0;
|
||||
|
||||
mp_clear(&s);
|
||||
mp_clear(&r);
|
||||
mp_clear(&u1);
|
||||
mp_clear(&u2);
|
||||
mp_clear(&w);
|
||||
mp_clear(&v);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
#endif /* NO_DSA */
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -1 +0,0 @@
|
||||
/* dummy ecc_fp.c for dist */
|
@ -1,814 +0,0 @@
|
||||
/* ed25519.c
|
||||
*
|
||||
* Copyright (C) 2006-2020 wolfSSL Inc.
|
||||
*
|
||||
* This file is part of wolfSSL.
|
||||
*
|
||||
* wolfSSL is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* wolfSSL is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA
|
||||
*/
|
||||
|
||||
|
||||
/* Based On Daniel J Bernstein's ed25519 Public Domain ref10 work. */
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
#endif
|
||||
|
||||
/* in case user set HAVE_ED25519 there */
|
||||
#include <wolfssl/wolfcrypt/settings.h>
|
||||
|
||||
#ifdef HAVE_ED25519
|
||||
|
||||
#include <wolfssl/wolfcrypt/ed25519.h>
|
||||
#include <wolfssl/wolfcrypt/error-crypt.h>
|
||||
#include <wolfssl/wolfcrypt/hash.h>
|
||||
#ifdef NO_INLINE
|
||||
#include <wolfssl/wolfcrypt/misc.h>
|
||||
#else
|
||||
#define WOLFSSL_MISC_INCLUDED
|
||||
#include <wolfcrypt/src/misc.c>
|
||||
#endif
|
||||
|
||||
#ifdef FREESCALE_LTC_ECC
|
||||
#include <wolfssl/wolfcrypt/port/nxp/ksdk_port.h>
|
||||
#endif
|
||||
|
||||
#if defined(HAVE_ED25519_SIGN) || defined(HAVE_ED25519_VERIFY)
|
||||
#define ED25519CTX_SIZE 32
|
||||
|
||||
static const byte ed25519Ctx[ED25519CTX_SIZE+1] =
|
||||
"SigEd25519 no Ed25519 collisions";
|
||||
#endif
|
||||
|
||||
int wc_ed25519_make_public(ed25519_key* key, unsigned char* pubKey,
|
||||
word32 pubKeySz)
|
||||
{
|
||||
int ret = 0;
|
||||
byte az[ED25519_PRV_KEY_SIZE];
|
||||
#if !defined(FREESCALE_LTC_ECC)
|
||||
ge_p3 A;
|
||||
#endif
|
||||
|
||||
if (key == NULL || pubKey == NULL || pubKeySz != ED25519_PUB_KEY_SIZE)
|
||||
ret = BAD_FUNC_ARG;
|
||||
|
||||
if (ret == 0)
|
||||
ret = wc_Sha512Hash(key->k, ED25519_KEY_SIZE, az);
|
||||
if (ret == 0) {
|
||||
/* apply clamp */
|
||||
az[0] &= 248;
|
||||
az[31] &= 63; /* same than az[31] &= 127 because of az[31] |= 64 */
|
||||
az[31] |= 64;
|
||||
|
||||
#ifdef FREESCALE_LTC_ECC
|
||||
ltc_pkha_ecc_point_t publicKey = {0};
|
||||
publicKey.X = key->pointX;
|
||||
publicKey.Y = key->pointY;
|
||||
LTC_PKHA_Ed25519_PointMul(LTC_PKHA_Ed25519_BasePoint(), az,
|
||||
ED25519_KEY_SIZE, &publicKey, kLTC_Ed25519 /* result on Ed25519 */);
|
||||
LTC_PKHA_Ed25519_Compress(&publicKey, pubKey);
|
||||
#else
|
||||
ge_scalarmult_base(&A, az);
|
||||
ge_p3_tobytes(pubKey, &A);
|
||||
#endif
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* generate an ed25519 key pair.
|
||||
* returns 0 on success
|
||||
*/
|
||||
int wc_ed25519_make_key(WC_RNG* rng, int keySz, ed25519_key* key)
|
||||
{
|
||||
int ret;
|
||||
|
||||
if (rng == NULL || key == NULL)
|
||||
return BAD_FUNC_ARG;
|
||||
|
||||
/* ed25519 has 32 byte key sizes */
|
||||
if (keySz != ED25519_KEY_SIZE)
|
||||
return BAD_FUNC_ARG;
|
||||
|
||||
ret = wc_RNG_GenerateBlock(rng, key->k, ED25519_KEY_SIZE);
|
||||
if (ret != 0)
|
||||
return ret;
|
||||
|
||||
ret = wc_ed25519_make_public(key, key->p, ED25519_PUB_KEY_SIZE);
|
||||
if (ret != 0) {
|
||||
ForceZero(key->k, ED25519_KEY_SIZE);
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* put public key after private key, on the same buffer */
|
||||
XMEMMOVE(key->k + ED25519_KEY_SIZE, key->p, ED25519_PUB_KEY_SIZE);
|
||||
|
||||
key->pubKeySet = 1;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
#ifdef HAVE_ED25519_SIGN
|
||||
/*
|
||||
in contains the message to sign
|
||||
inLen is the length of the message to sign
|
||||
out is the buffer to write the signature
|
||||
outLen [in/out] input size of out buf
|
||||
output gets set as the final length of out
|
||||
key is the ed25519 key to use when signing
|
||||
type one of Ed25519, Ed25519ctx or Ed25519ph
|
||||
context extra signing data
|
||||
contextLen length of extra signing data
|
||||
return 0 on success
|
||||
*/
|
||||
static int ed25519_sign_msg(const byte* in, word32 inLen, byte* out,
|
||||
word32 *outLen, ed25519_key* key, byte type,
|
||||
const byte* context, byte contextLen)
|
||||
{
|
||||
#ifdef FREESCALE_LTC_ECC
|
||||
byte tempBuf[ED25519_PRV_KEY_SIZE];
|
||||
#else
|
||||
ge_p3 R;
|
||||
#endif
|
||||
byte nonce[WC_SHA512_DIGEST_SIZE];
|
||||
byte hram[WC_SHA512_DIGEST_SIZE];
|
||||
byte az[ED25519_PRV_KEY_SIZE];
|
||||
wc_Sha512 sha;
|
||||
int ret;
|
||||
|
||||
/* sanity check on arguments */
|
||||
if (in == NULL || out == NULL || outLen == NULL || key == NULL ||
|
||||
(context == NULL && contextLen != 0)) {
|
||||
return BAD_FUNC_ARG;
|
||||
}
|
||||
if (!key->pubKeySet)
|
||||
return BAD_FUNC_ARG;
|
||||
|
||||
/* check and set up out length */
|
||||
if (*outLen < ED25519_SIG_SIZE) {
|
||||
*outLen = ED25519_SIG_SIZE;
|
||||
return BUFFER_E;
|
||||
}
|
||||
*outLen = ED25519_SIG_SIZE;
|
||||
|
||||
/* step 1: create nonce to use where nonce is r in
|
||||
r = H(h_b, ... ,h_2b-1,M) */
|
||||
ret = wc_Sha512Hash(key->k, ED25519_KEY_SIZE, az);
|
||||
if (ret != 0)
|
||||
return ret;
|
||||
|
||||
/* apply clamp */
|
||||
az[0] &= 248;
|
||||
az[31] &= 63; /* same than az[31] &= 127 because of az[31] |= 64 */
|
||||
az[31] |= 64;
|
||||
|
||||
ret = wc_InitSha512(&sha);
|
||||
if (ret != 0)
|
||||
return ret;
|
||||
if (type == Ed25519ctx || type == Ed25519ph) {
|
||||
ret = wc_Sha512Update(&sha, ed25519Ctx, ED25519CTX_SIZE);
|
||||
if (ret == 0)
|
||||
ret = wc_Sha512Update(&sha, &type, sizeof(type));
|
||||
if (ret == 0)
|
||||
ret = wc_Sha512Update(&sha, &contextLen, sizeof(contextLen));
|
||||
if (ret == 0 && context != NULL)
|
||||
ret = wc_Sha512Update(&sha, context, contextLen);
|
||||
}
|
||||
if (ret == 0)
|
||||
ret = wc_Sha512Update(&sha, az + ED25519_KEY_SIZE, ED25519_KEY_SIZE);
|
||||
if (ret == 0)
|
||||
ret = wc_Sha512Update(&sha, in, inLen);
|
||||
if (ret == 0)
|
||||
ret = wc_Sha512Final(&sha, nonce);
|
||||
wc_Sha512Free(&sha);
|
||||
if (ret != 0)
|
||||
return ret;
|
||||
|
||||
#ifdef FREESCALE_LTC_ECC
|
||||
ltc_pkha_ecc_point_t ltcPoint = {0};
|
||||
ltcPoint.X = &tempBuf[0];
|
||||
ltcPoint.Y = &tempBuf[32];
|
||||
LTC_PKHA_sc_reduce(nonce);
|
||||
LTC_PKHA_Ed25519_PointMul(LTC_PKHA_Ed25519_BasePoint(), nonce,
|
||||
ED25519_KEY_SIZE, <cPoint, kLTC_Ed25519 /* result on Ed25519 */);
|
||||
LTC_PKHA_Ed25519_Compress(<cPoint, out);
|
||||
#else
|
||||
sc_reduce(nonce);
|
||||
|
||||
/* step 2: computing R = rB where rB is the scalar multiplication of
|
||||
r and B */
|
||||
ge_scalarmult_base(&R,nonce);
|
||||
ge_p3_tobytes(out,&R);
|
||||
#endif
|
||||
|
||||
/* step 3: hash R + public key + message getting H(R,A,M) then
|
||||
creating S = (r + H(R,A,M)a) mod l */
|
||||
ret = wc_InitSha512(&sha);
|
||||
if (ret != 0)
|
||||
return ret;
|
||||
if (type == Ed25519ctx || type == Ed25519ph) {
|
||||
ret = wc_Sha512Update(&sha, ed25519Ctx, ED25519CTX_SIZE);
|
||||
if (ret == 0)
|
||||
ret = wc_Sha512Update(&sha, &type, sizeof(type));
|
||||
if (ret == 0)
|
||||
ret = wc_Sha512Update(&sha, &contextLen, sizeof(contextLen));
|
||||
if (ret == 0 && context != NULL)
|
||||
ret = wc_Sha512Update(&sha, context, contextLen);
|
||||
}
|
||||
if (ret == 0)
|
||||
ret = wc_Sha512Update(&sha, out, ED25519_SIG_SIZE/2);
|
||||
if (ret == 0)
|
||||
ret = wc_Sha512Update(&sha, key->p, ED25519_PUB_KEY_SIZE);
|
||||
if (ret == 0)
|
||||
ret = wc_Sha512Update(&sha, in, inLen);
|
||||
if (ret == 0)
|
||||
ret = wc_Sha512Final(&sha, hram);
|
||||
wc_Sha512Free(&sha);
|
||||
if (ret != 0)
|
||||
return ret;
|
||||
|
||||
#ifdef FREESCALE_LTC_ECC
|
||||
LTC_PKHA_sc_reduce(hram);
|
||||
LTC_PKHA_sc_muladd(out + (ED25519_SIG_SIZE/2), hram, az, nonce);
|
||||
#else
|
||||
sc_reduce(hram);
|
||||
sc_muladd(out + (ED25519_SIG_SIZE/2), hram, az, nonce);
|
||||
#endif
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/*
|
||||
in contains the message to sign
|
||||
inLen is the length of the message to sign
|
||||
out is the buffer to write the signature
|
||||
outLen [in/out] input size of out buf
|
||||
output gets set as the final length of out
|
||||
key is the ed25519 key to use when signing
|
||||
return 0 on success
|
||||
*/
|
||||
int wc_ed25519_sign_msg(const byte* in, word32 inLen, byte* out,
|
||||
word32 *outLen, ed25519_key* key)
|
||||
{
|
||||
return ed25519_sign_msg(in, inLen, out, outLen, key, (byte)Ed25519, NULL, 0);
|
||||
}
|
||||
|
||||
/*
|
||||
in contains the message to sign
|
||||
inLen is the length of the message to sign
|
||||
out is the buffer to write the signature
|
||||
outLen [in/out] input size of out buf
|
||||
output gets set as the final length of out
|
||||
key is the ed25519 key to use when signing
|
||||
context extra signing data
|
||||
contextLen length of extra signing data
|
||||
return 0 on success
|
||||
*/
|
||||
int wc_ed25519ctx_sign_msg(const byte* in, word32 inLen, byte* out,
|
||||
word32 *outLen, ed25519_key* key,
|
||||
const byte* context, byte contextLen)
|
||||
{
|
||||
return ed25519_sign_msg(in, inLen, out, outLen, key, Ed25519ctx, context,
|
||||
contextLen);
|
||||
}
|
||||
|
||||
/*
|
||||
hash contains the SHA-512 hash of the message to sign
|
||||
hashLen is the length of the SHA-512 hash of the message to sign
|
||||
out is the buffer to write the signature
|
||||
outLen [in/out] input size of out buf
|
||||
output gets set as the final length of out
|
||||
key is the ed25519 key to use when signing
|
||||
context extra signing data
|
||||
contextLen length of extra signing data
|
||||
return 0 on success
|
||||
*/
|
||||
int wc_ed25519ph_sign_hash(const byte* hash, word32 hashLen, byte* out,
|
||||
word32 *outLen, ed25519_key* key,
|
||||
const byte* context, byte contextLen)
|
||||
{
|
||||
return ed25519_sign_msg(hash, hashLen, out, outLen, key, Ed25519ph, context,
|
||||
contextLen);
|
||||
}
|
||||
|
||||
/*
|
||||
in contains the message to sign
|
||||
inLen is the length of the message to sign
|
||||
out is the buffer to write the signature
|
||||
outLen [in/out] input size of out buf
|
||||
output gets set as the final length of out
|
||||
key is the ed25519 key to use when signing
|
||||
context extra signing data
|
||||
contextLen length of extra signing data
|
||||
return 0 on success
|
||||
*/
|
||||
int wc_ed25519ph_sign_msg(const byte* in, word32 inLen, byte* out,
|
||||
word32 *outLen, ed25519_key* key,
|
||||
const byte* context, byte contextLen)
|
||||
{
|
||||
int ret;
|
||||
byte hash[WC_SHA512_DIGEST_SIZE];
|
||||
|
||||
ret = wc_Sha512Hash(in, inLen, hash);
|
||||
if (ret != 0)
|
||||
return ret;
|
||||
|
||||
return wc_ed25519ph_sign_hash(hash, sizeof(hash), out, outLen, key, context,
|
||||
contextLen);
|
||||
}
|
||||
#endif /* HAVE_ED25519_SIGN */
|
||||
|
||||
#ifdef HAVE_ED25519_VERIFY
|
||||
|
||||
/*
|
||||
sig is array of bytes containing the signature
|
||||
sigLen is the length of sig byte array
|
||||
msg the array of bytes containing the message
|
||||
msgLen length of msg array
|
||||
res will be 1 on successful verify and 0 on unsuccessful
|
||||
key Ed25519 public key
|
||||
return 0 and res of 1 on success
|
||||
*/
|
||||
static int ed25519_verify_msg(const byte* sig, word32 sigLen, const byte* msg,
|
||||
word32 msgLen, int* res, ed25519_key* key,
|
||||
byte type, const byte* context, byte contextLen)
|
||||
{
|
||||
byte rcheck[ED25519_KEY_SIZE];
|
||||
byte h[WC_SHA512_DIGEST_SIZE];
|
||||
#ifndef FREESCALE_LTC_ECC
|
||||
ge_p3 A;
|
||||
ge_p2 R;
|
||||
#endif
|
||||
int ret;
|
||||
wc_Sha512 sha;
|
||||
|
||||
/* sanity check on arguments */
|
||||
if (sig == NULL || msg == NULL || res == NULL || key == NULL ||
|
||||
(context == NULL && contextLen != 0)) {
|
||||
return BAD_FUNC_ARG;
|
||||
}
|
||||
|
||||
/* set verification failed by default */
|
||||
*res = 0;
|
||||
|
||||
/* check on basics needed to verify signature */
|
||||
if (sigLen != ED25519_SIG_SIZE || (sig[ED25519_SIG_SIZE-1] & 224))
|
||||
return BAD_FUNC_ARG;
|
||||
|
||||
/* uncompress A (public key), test if valid, and negate it */
|
||||
#ifndef FREESCALE_LTC_ECC
|
||||
if (ge_frombytes_negate_vartime(&A, key->p) != 0)
|
||||
return BAD_FUNC_ARG;
|
||||
#endif
|
||||
|
||||
/* find H(R,A,M) and store it as h */
|
||||
ret = wc_InitSha512(&sha);
|
||||
if (ret != 0)
|
||||
return ret;
|
||||
if (type == Ed25519ctx || type == Ed25519ph) {
|
||||
ret = wc_Sha512Update(&sha, ed25519Ctx, ED25519CTX_SIZE);
|
||||
if (ret == 0)
|
||||
ret = wc_Sha512Update(&sha, &type, sizeof(type));
|
||||
if (ret == 0)
|
||||
ret = wc_Sha512Update(&sha, &contextLen, sizeof(contextLen));
|
||||
if (ret == 0 && context != NULL)
|
||||
ret = wc_Sha512Update(&sha, context, contextLen);
|
||||
}
|
||||
if (ret == 0)
|
||||
ret = wc_Sha512Update(&sha, sig, ED25519_SIG_SIZE/2);
|
||||
if (ret == 0)
|
||||
ret = wc_Sha512Update(&sha, key->p, ED25519_PUB_KEY_SIZE);
|
||||
if (ret == 0)
|
||||
ret = wc_Sha512Update(&sha, msg, msgLen);
|
||||
if (ret == 0)
|
||||
ret = wc_Sha512Final(&sha, h);
|
||||
wc_Sha512Free(&sha);
|
||||
if (ret != 0)
|
||||
return ret;
|
||||
|
||||
#ifdef FREESCALE_LTC_ECC
|
||||
LTC_PKHA_sc_reduce(h);
|
||||
LTC_PKHA_SignatureForVerify(rcheck, h, sig + (ED25519_SIG_SIZE/2), key);
|
||||
#else
|
||||
sc_reduce(h);
|
||||
|
||||
/*
|
||||
Uses a fast single-signature verification SB = R + H(R,A,M)A becomes
|
||||
SB - H(R,A,M)A saving decompression of R
|
||||
*/
|
||||
ret = ge_double_scalarmult_vartime(&R, h, &A, sig + (ED25519_SIG_SIZE/2));
|
||||
if (ret != 0)
|
||||
return ret;
|
||||
|
||||
ge_tobytes(rcheck, &R);
|
||||
#endif /* FREESCALE_LTC_ECC */
|
||||
|
||||
/* comparison of R created to R in sig */
|
||||
ret = ConstantCompare(rcheck, sig, ED25519_SIG_SIZE/2);
|
||||
if (ret != 0)
|
||||
return SIG_VERIFY_E;
|
||||
|
||||
/* set the verification status */
|
||||
*res = 1;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/*
|
||||
sig is array of bytes containing the signature
|
||||
sigLen is the length of sig byte array
|
||||
msg the array of bytes containing the message
|
||||
msgLen length of msg array
|
||||
res will be 1 on successful verify and 0 on unsuccessful
|
||||
key Ed25519 public key
|
||||
return 0 and res of 1 on success
|
||||
*/
|
||||
int wc_ed25519_verify_msg(const byte* sig, word32 sigLen, const byte* msg,
|
||||
word32 msgLen, int* res, ed25519_key* key)
|
||||
{
|
||||
return ed25519_verify_msg(sig, sigLen, msg, msgLen, res, key, (byte)Ed25519,
|
||||
NULL, 0);
|
||||
}
|
||||
|
||||
/*
|
||||
sig is array of bytes containing the signature
|
||||
sigLen is the length of sig byte array
|
||||
msg the array of bytes containing the message
|
||||
msgLen length of msg array
|
||||
res will be 1 on successful verify and 0 on unsuccessful
|
||||
key Ed25519 public key
|
||||
context extra sigining data
|
||||
contextLen length of extra sigining data
|
||||
return 0 and res of 1 on success
|
||||
*/
|
||||
int wc_ed25519ctx_verify_msg(const byte* sig, word32 sigLen, const byte* msg,
|
||||
word32 msgLen, int* res, ed25519_key* key,
|
||||
const byte* context, byte contextLen)
|
||||
{
|
||||
return ed25519_verify_msg(sig, sigLen, msg, msgLen, res, key, Ed25519ctx,
|
||||
context, contextLen);
|
||||
}
|
||||
|
||||
/*
|
||||
sig is array of bytes containing the signature
|
||||
sigLen is the length of sig byte array
|
||||
hash the array of bytes containing the SHA-512 hash of the message
|
||||
hashLen length of hash array
|
||||
res will be 1 on successful verify and 0 on unsuccessful
|
||||
key Ed25519 public key
|
||||
context extra sigining data
|
||||
contextLen length of extra sigining data
|
||||
return 0 and res of 1 on success
|
||||
*/
|
||||
int wc_ed25519ph_verify_hash(const byte* sig, word32 sigLen, const byte* hash,
|
||||
word32 hashLen, int* res, ed25519_key* key,
|
||||
const byte* context, byte contextLen)
|
||||
{
|
||||
return ed25519_verify_msg(sig, sigLen, hash, hashLen, res, key, Ed25519ph,
|
||||
context, contextLen);
|
||||
}
|
||||
|
||||
/*
|
||||
sig is array of bytes containing the signature
|
||||
sigLen is the length of sig byte array
|
||||
msg the array of bytes containing the message
|
||||
msgLen length of msg array
|
||||
res will be 1 on successful verify and 0 on unsuccessful
|
||||
key Ed25519 public key
|
||||
context extra sigining data
|
||||
contextLen length of extra sigining data
|
||||
return 0 and res of 1 on success
|
||||
*/
|
||||
int wc_ed25519ph_verify_msg(const byte* sig, word32 sigLen, const byte* msg,
|
||||
word32 msgLen, int* res, ed25519_key* key,
|
||||
const byte* context, byte contextLen)
|
||||
{
|
||||
int ret;
|
||||
byte hash[WC_SHA512_DIGEST_SIZE];
|
||||
|
||||
ret = wc_Sha512Hash(msg, msgLen, hash);
|
||||
if (ret != 0)
|
||||
return ret;
|
||||
|
||||
return wc_ed25519ph_verify_hash(sig, sigLen, hash, sizeof(hash), res, key,
|
||||
context, contextLen);
|
||||
}
|
||||
#endif /* HAVE_ED25519_VERIFY */
|
||||
|
||||
|
||||
/* initialize information and memory for key */
|
||||
int wc_ed25519_init(ed25519_key* key)
|
||||
{
|
||||
if (key == NULL)
|
||||
return BAD_FUNC_ARG;
|
||||
|
||||
XMEMSET(key, 0, sizeof(ed25519_key));
|
||||
|
||||
#ifndef FREESCALE_LTC_ECC
|
||||
fe_init();
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/* clear memory of key */
|
||||
void wc_ed25519_free(ed25519_key* key)
|
||||
{
|
||||
if (key == NULL)
|
||||
return;
|
||||
|
||||
ForceZero(key, sizeof(ed25519_key));
|
||||
}
|
||||
|
||||
|
||||
#ifdef HAVE_ED25519_KEY_EXPORT
|
||||
|
||||
/*
|
||||
outLen should contain the size of out buffer when input. outLen is than set
|
||||
to the final output length.
|
||||
returns 0 on success
|
||||
*/
|
||||
int wc_ed25519_export_public(ed25519_key* key, byte* out, word32* outLen)
|
||||
{
|
||||
/* sanity check on arguments */
|
||||
if (key == NULL || out == NULL || outLen == NULL)
|
||||
return BAD_FUNC_ARG;
|
||||
|
||||
if (*outLen < ED25519_PUB_KEY_SIZE) {
|
||||
*outLen = ED25519_PUB_KEY_SIZE;
|
||||
return BUFFER_E;
|
||||
}
|
||||
|
||||
*outLen = ED25519_PUB_KEY_SIZE;
|
||||
XMEMCPY(out, key->p, ED25519_PUB_KEY_SIZE);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif /* HAVE_ED25519_KEY_EXPORT */
|
||||
|
||||
|
||||
#ifdef HAVE_ED25519_KEY_IMPORT
|
||||
/*
|
||||
Imports a compressed/uncompressed public key.
|
||||
in the byte array containing the public key
|
||||
inLen the length of the byte array being passed in
|
||||
key ed25519 key struct to put the public key in
|
||||
*/
|
||||
int wc_ed25519_import_public(const byte* in, word32 inLen, ed25519_key* key)
|
||||
{
|
||||
int ret;
|
||||
|
||||
/* sanity check on arguments */
|
||||
if (in == NULL || key == NULL)
|
||||
return BAD_FUNC_ARG;
|
||||
|
||||
if (inLen < ED25519_PUB_KEY_SIZE)
|
||||
return BAD_FUNC_ARG;
|
||||
|
||||
/* compressed prefix according to draft
|
||||
http://www.ietf.org/id/draft-koch-eddsa-for-openpgp-02.txt */
|
||||
if (in[0] == 0x40 && inLen > ED25519_PUB_KEY_SIZE) {
|
||||
/* key is stored in compressed format so just copy in */
|
||||
XMEMCPY(key->p, (in + 1), ED25519_PUB_KEY_SIZE);
|
||||
#ifdef FREESCALE_LTC_ECC
|
||||
/* recover X coordinate */
|
||||
ltc_pkha_ecc_point_t pubKey;
|
||||
pubKey.X = key->pointX;
|
||||
pubKey.Y = key->pointY;
|
||||
LTC_PKHA_Ed25519_PointDecompress(key->p, ED25519_PUB_KEY_SIZE, &pubKey);
|
||||
#endif
|
||||
key->pubKeySet = 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* importing uncompressed public key */
|
||||
if (in[0] == 0x04 && inLen > 2*ED25519_PUB_KEY_SIZE) {
|
||||
#ifdef FREESCALE_LTC_ECC
|
||||
/* reverse bytes for little endian byte order */
|
||||
for (int i = 0; i < ED25519_KEY_SIZE; i++)
|
||||
{
|
||||
key->pointX[i] = *(in + ED25519_KEY_SIZE - i);
|
||||
key->pointY[i] = *(in + 2*ED25519_KEY_SIZE - i);
|
||||
}
|
||||
XMEMCPY(key->p, key->pointY, ED25519_KEY_SIZE);
|
||||
key->pubKeySet = 1;
|
||||
ret = 0;
|
||||
#else
|
||||
/* pass in (x,y) and store compressed key */
|
||||
ret = ge_compress_key(key->p, in+1,
|
||||
in+1+ED25519_PUB_KEY_SIZE, ED25519_PUB_KEY_SIZE);
|
||||
if (ret == 0)
|
||||
key->pubKeySet = 1;
|
||||
#endif /* FREESCALE_LTC_ECC */
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* if not specified compressed or uncompressed check key size
|
||||
if key size is equal to compressed key size copy in key */
|
||||
if (inLen == ED25519_PUB_KEY_SIZE) {
|
||||
XMEMCPY(key->p, in, ED25519_PUB_KEY_SIZE);
|
||||
#ifdef FREESCALE_LTC_ECC
|
||||
/* recover X coordinate */
|
||||
ltc_pkha_ecc_point_t pubKey;
|
||||
pubKey.X = key->pointX;
|
||||
pubKey.Y = key->pointY;
|
||||
LTC_PKHA_Ed25519_PointDecompress(key->p, ED25519_PUB_KEY_SIZE, &pubKey);
|
||||
#endif
|
||||
key->pubKeySet = 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* bad public key format */
|
||||
return BAD_FUNC_ARG;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
For importing a private key.
|
||||
*/
|
||||
int wc_ed25519_import_private_only(const byte* priv, word32 privSz,
|
||||
ed25519_key* key)
|
||||
{
|
||||
/* sanity check on arguments */
|
||||
if (priv == NULL || key == NULL)
|
||||
return BAD_FUNC_ARG;
|
||||
|
||||
/* key size check */
|
||||
if (privSz < ED25519_KEY_SIZE)
|
||||
return BAD_FUNC_ARG;
|
||||
|
||||
XMEMCPY(key->k, priv, ED25519_KEY_SIZE);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
For importing a private key and its associated public key.
|
||||
*/
|
||||
int wc_ed25519_import_private_key(const byte* priv, word32 privSz,
|
||||
const byte* pub, word32 pubSz, ed25519_key* key)
|
||||
{
|
||||
int ret;
|
||||
|
||||
/* sanity check on arguments */
|
||||
if (priv == NULL || pub == NULL || key == NULL)
|
||||
return BAD_FUNC_ARG;
|
||||
|
||||
/* key size check */
|
||||
if (privSz < ED25519_KEY_SIZE || pubSz < ED25519_PUB_KEY_SIZE)
|
||||
return BAD_FUNC_ARG;
|
||||
|
||||
/* import public key */
|
||||
ret = wc_ed25519_import_public(pub, pubSz, key);
|
||||
if (ret != 0)
|
||||
return ret;
|
||||
|
||||
/* make the private key (priv + pub) */
|
||||
XMEMCPY(key->k, priv, ED25519_KEY_SIZE);
|
||||
XMEMCPY(key->k + ED25519_KEY_SIZE, key->p, ED25519_PUB_KEY_SIZE);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
#endif /* HAVE_ED25519_KEY_IMPORT */
|
||||
|
||||
|
||||
#ifdef HAVE_ED25519_KEY_EXPORT
|
||||
|
||||
/*
|
||||
export private key only (secret part so 32 bytes)
|
||||
outLen should contain the size of out buffer when input. outLen is than set
|
||||
to the final output length.
|
||||
returns 0 on success
|
||||
*/
|
||||
int wc_ed25519_export_private_only(ed25519_key* key, byte* out, word32* outLen)
|
||||
{
|
||||
/* sanity checks on arguments */
|
||||
if (key == NULL || out == NULL || outLen == NULL)
|
||||
return BAD_FUNC_ARG;
|
||||
|
||||
if (*outLen < ED25519_KEY_SIZE) {
|
||||
*outLen = ED25519_KEY_SIZE;
|
||||
return BUFFER_E;
|
||||
}
|
||||
|
||||
*outLen = ED25519_KEY_SIZE;
|
||||
XMEMCPY(out, key->k, ED25519_KEY_SIZE);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
export private key, including public part
|
||||
outLen should contain the size of out buffer when input. outLen is than set
|
||||
to the final output length.
|
||||
returns 0 on success
|
||||
*/
|
||||
int wc_ed25519_export_private(ed25519_key* key, byte* out, word32* outLen)
|
||||
{
|
||||
/* sanity checks on arguments */
|
||||
if (key == NULL || out == NULL || outLen == NULL)
|
||||
return BAD_FUNC_ARG;
|
||||
|
||||
if (*outLen < ED25519_PRV_KEY_SIZE) {
|
||||
*outLen = ED25519_PRV_KEY_SIZE;
|
||||
return BUFFER_E;
|
||||
}
|
||||
|
||||
*outLen = ED25519_PRV_KEY_SIZE;
|
||||
XMEMCPY(out, key->k, ED25519_PRV_KEY_SIZE);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* export full private key and public key
|
||||
return 0 on success
|
||||
*/
|
||||
int wc_ed25519_export_key(ed25519_key* key,
|
||||
byte* priv, word32 *privSz,
|
||||
byte* pub, word32 *pubSz)
|
||||
{
|
||||
int ret;
|
||||
|
||||
/* export 'full' private part */
|
||||
ret = wc_ed25519_export_private(key, priv, privSz);
|
||||
if (ret != 0)
|
||||
return ret;
|
||||
|
||||
/* export public part */
|
||||
ret = wc_ed25519_export_public(key, pub, pubSz);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
#endif /* HAVE_ED25519_KEY_EXPORT */
|
||||
|
||||
/* check the private and public keys match */
|
||||
int wc_ed25519_check_key(ed25519_key* key)
|
||||
{
|
||||
int ret = 0;
|
||||
unsigned char pubKey[ED25519_PUB_KEY_SIZE];
|
||||
|
||||
if (!key->pubKeySet)
|
||||
ret = PUBLIC_KEY_E;
|
||||
if (ret == 0)
|
||||
ret = wc_ed25519_make_public(key, pubKey, sizeof(pubKey));
|
||||
if (ret == 0 && XMEMCMP(pubKey, key->p, ED25519_PUB_KEY_SIZE) != 0)
|
||||
ret = PUBLIC_KEY_E;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* returns the private key size (secret only) in bytes */
|
||||
int wc_ed25519_size(ed25519_key* key)
|
||||
{
|
||||
if (key == NULL)
|
||||
return BAD_FUNC_ARG;
|
||||
|
||||
return ED25519_KEY_SIZE;
|
||||
}
|
||||
|
||||
/* returns the private key size (secret + public) in bytes */
|
||||
int wc_ed25519_priv_size(ed25519_key* key)
|
||||
{
|
||||
if (key == NULL)
|
||||
return BAD_FUNC_ARG;
|
||||
|
||||
return ED25519_PRV_KEY_SIZE;
|
||||
}
|
||||
|
||||
/* returns the compressed key size in bytes (public key) */
|
||||
int wc_ed25519_pub_size(ed25519_key* key)
|
||||
{
|
||||
if (key == NULL)
|
||||
return BAD_FUNC_ARG;
|
||||
|
||||
return ED25519_PUB_KEY_SIZE;
|
||||
}
|
||||
|
||||
/* returns the size of signature in bytes */
|
||||
int wc_ed25519_sig_size(ed25519_key* key)
|
||||
{
|
||||
if (key == NULL)
|
||||
return BAD_FUNC_ARG;
|
||||
|
||||
return ED25519_SIG_SIZE;
|
||||
}
|
||||
|
||||
#endif /* HAVE_ED25519 */
|
||||
|
@ -1,922 +0,0 @@
|
||||
/* ed448.c
|
||||
*
|
||||
* Copyright (C) 2006-2020 wolfSSL Inc.
|
||||
*
|
||||
* This file is part of wolfSSL.
|
||||
*
|
||||
* wolfSSL is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* wolfSSL is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA
|
||||
*/
|
||||
|
||||
/* Implemented to: RFC 8032 */
|
||||
|
||||
/* Based On Daniel J Bernstein's ed25519 Public Domain ref10 work.
|
||||
* Reworked for curve448 by Sean Parkinson.
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
#endif
|
||||
|
||||
/* in case user set HAVE_ED448 there */
|
||||
#include <wolfssl/wolfcrypt/settings.h>
|
||||
|
||||
#ifdef HAVE_ED448
|
||||
|
||||
#include <wolfssl/wolfcrypt/ed448.h>
|
||||
#include <wolfssl/wolfcrypt/error-crypt.h>
|
||||
#include <wolfssl/wolfcrypt/hash.h>
|
||||
#ifdef NO_INLINE
|
||||
#include <wolfssl/wolfcrypt/misc.h>
|
||||
#else
|
||||
#define WOLFSSL_MISC_INCLUDED
|
||||
#include <wolfcrypt/src/misc.c>
|
||||
#endif
|
||||
|
||||
#if defined(HAVE_ED448_SIGN) || defined(HAVE_ED448_VERIFY)
|
||||
/* Size of context bytes to use with hash when signing and verifying. */
|
||||
#define ED448CTX_SIZE 8
|
||||
/* Context to pass to hash when signing and verifying. */
|
||||
static const byte ed448Ctx[ED448CTX_SIZE+1] = "SigEd448";
|
||||
#endif
|
||||
|
||||
/* Derive the public key for the private key.
|
||||
*
|
||||
* key [in] Ed448 key object.
|
||||
* pubKey [in] Byte array to hold te public key.
|
||||
* pubKeySz [in] Size of the array in bytes.
|
||||
* returns BAD_FUNC_ARG when key is NULL or pubKeySz is not equal to
|
||||
* ED448_PUB_KEY_SIZE,
|
||||
* other -ve value on hash failure,
|
||||
* 0 otherwise.
|
||||
*/
|
||||
int wc_ed448_make_public(ed448_key* key, unsigned char* pubKey, word32 pubKeySz)
|
||||
{
|
||||
int ret = 0;
|
||||
byte az[ED448_PRV_KEY_SIZE];
|
||||
ge448_p2 A;
|
||||
|
||||
if ((key == NULL) || (pubKey == NULL) || (pubKeySz != ED448_PUB_KEY_SIZE)) {
|
||||
ret = BAD_FUNC_ARG;
|
||||
}
|
||||
|
||||
if (ret == 0) {
|
||||
ret = wc_Shake256Hash(key->k, ED448_KEY_SIZE, az, sizeof(az));
|
||||
}
|
||||
if (ret == 0) {
|
||||
/* apply clamp */
|
||||
az[0] &= 0xfc;
|
||||
az[55] |= 0x80;
|
||||
az[56] = 0x00;
|
||||
|
||||
ge448_scalarmult_base(&A, az);
|
||||
ge448_to_bytes(pubKey, &A);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* Make a new ed448 private/public key.
|
||||
*
|
||||
* rng [in] Random number generator.
|
||||
* keysize [in] Size of the key to generate.
|
||||
* key [in] Ed448 key object.
|
||||
* returns BAD_FUNC_ARG when rng or key is NULL or keySz is not equal to
|
||||
* ED448_KEY_SIZE,
|
||||
* other -ve value on random number or hash failure,
|
||||
* 0 otherwise.
|
||||
*/
|
||||
int wc_ed448_make_key(WC_RNG* rng, int keySz, ed448_key* key)
|
||||
{
|
||||
int ret = 0;
|
||||
|
||||
if ((rng == NULL) || (key == NULL)) {
|
||||
ret = BAD_FUNC_ARG;
|
||||
}
|
||||
|
||||
/* ed448 has 57 byte key sizes */
|
||||
if ((ret == 0) && (keySz != ED448_KEY_SIZE)) {
|
||||
ret = BAD_FUNC_ARG;
|
||||
}
|
||||
|
||||
if (ret == 0) {
|
||||
ret = wc_RNG_GenerateBlock(rng, key->k, ED448_KEY_SIZE);
|
||||
}
|
||||
if (ret == 0) {
|
||||
ret = wc_ed448_make_public(key, key->p, ED448_PUB_KEY_SIZE);
|
||||
if (ret != 0) {
|
||||
ForceZero(key->k, ED448_KEY_SIZE);
|
||||
}
|
||||
}
|
||||
if (ret == 0) {
|
||||
/* put public key after private key, on the same buffer */
|
||||
XMEMMOVE(key->k + ED448_KEY_SIZE, key->p, ED448_PUB_KEY_SIZE);
|
||||
|
||||
key->pubKeySet = 1;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
#ifdef HAVE_ED448_SIGN
|
||||
/* Sign the message using the ed448 private key.
|
||||
*
|
||||
* in [in] Message to sign.
|
||||
* inLen [in] Length of the message in bytes.
|
||||
* out [in] Buffer to write signature into.
|
||||
* outLen [in/out] On in, size of buffer.
|
||||
* On out, the length of the signature in bytes.
|
||||
* key [in] Ed448 key to use when signing
|
||||
* type [in] Type of signature to perform: Ed448 or Ed448ph
|
||||
* context [in] Context of signing.
|
||||
* contextLen [in] Length of context in bytes.
|
||||
* returns BAD_FUNC_ARG when a parameter is NULL or contextLen is zero when and
|
||||
* context is not NULL or public key not set,
|
||||
* BUFFER_E when outLen is less than ED448_SIG_SIZE,
|
||||
* other -ve values when hash fails,
|
||||
* 0 otherwise.
|
||||
*/
|
||||
static int ed448_sign_msg(const byte* in, word32 inLen, byte* out,
|
||||
word32 *outLen, ed448_key* key, byte type,
|
||||
const byte* context, byte contextLen)
|
||||
{
|
||||
ge448_p2 R;
|
||||
byte nonce[ED448_SIG_SIZE];
|
||||
byte hram[ED448_SIG_SIZE];
|
||||
byte az[ED448_PRV_KEY_SIZE];
|
||||
wc_Shake sha;
|
||||
int ret = 0;
|
||||
|
||||
/* sanity check on arguments */
|
||||
if ((in == NULL) || (out == NULL) || (outLen == NULL) || (key == NULL) ||
|
||||
((context == NULL) && (contextLen != 0))) {
|
||||
ret = BAD_FUNC_ARG;
|
||||
}
|
||||
if ((ret == 0) && (!key->pubKeySet)) {
|
||||
ret = BAD_FUNC_ARG;
|
||||
}
|
||||
|
||||
/* check and set up out length */
|
||||
if ((ret == 0) && (*outLen < ED448_SIG_SIZE)) {
|
||||
*outLen = ED448_SIG_SIZE;
|
||||
ret = BUFFER_E;
|
||||
}
|
||||
|
||||
if (ret == 0) {
|
||||
*outLen = ED448_SIG_SIZE;
|
||||
|
||||
/* step 1: create nonce to use where nonce is r in
|
||||
r = H(h_b, ... ,h_2b-1,M) */
|
||||
ret = wc_Shake256Hash(key->k, ED448_KEY_SIZE, az, sizeof(az));
|
||||
}
|
||||
if (ret == 0) {
|
||||
/* apply clamp */
|
||||
az[0] &= 0xfc;
|
||||
az[55] |= 0x80;
|
||||
az[56] = 0x00;
|
||||
|
||||
ret = wc_InitShake256(&sha, NULL, INVALID_DEVID);
|
||||
if (ret == 0) {
|
||||
ret = wc_Shake256_Update(&sha, ed448Ctx, ED448CTX_SIZE);
|
||||
}
|
||||
if (ret == 0) {
|
||||
ret = wc_Shake256_Update(&sha, &type, sizeof(type));
|
||||
}
|
||||
if (ret == 0) {
|
||||
ret = wc_Shake256_Update(&sha, &contextLen, sizeof(contextLen));
|
||||
}
|
||||
if ((ret == 0) && (context != NULL)) {
|
||||
ret = wc_Shake256_Update(&sha, context, contextLen);
|
||||
}
|
||||
if (ret == 0) {
|
||||
ret = wc_Shake256_Update(&sha, az + ED448_KEY_SIZE, ED448_KEY_SIZE);
|
||||
}
|
||||
if (ret == 0) {
|
||||
ret = wc_Shake256_Update(&sha, in, inLen);
|
||||
}
|
||||
if (ret == 0) {
|
||||
ret = wc_Shake256_Final(&sha, nonce, sizeof(nonce));
|
||||
}
|
||||
wc_Shake256_Free(&sha);
|
||||
}
|
||||
if (ret == 0) {
|
||||
sc448_reduce(nonce);
|
||||
|
||||
/* step 2: computing R = rB where rB is the scalar multiplication of
|
||||
r and B */
|
||||
ge448_scalarmult_base(&R,nonce);
|
||||
ge448_to_bytes(out,&R);
|
||||
|
||||
/* step 3: hash R + public key + message getting H(R,A,M) then
|
||||
creating S = (r + H(R,A,M)a) mod l */
|
||||
ret = wc_InitShake256(&sha, NULL, INVALID_DEVID);
|
||||
if (ret == 0) {
|
||||
ret = wc_Shake256_Update(&sha, ed448Ctx, ED448CTX_SIZE);
|
||||
if (ret == 0) {
|
||||
ret = wc_Shake256_Update(&sha, &type, sizeof(type));
|
||||
}
|
||||
if (ret == 0) {
|
||||
ret = wc_Shake256_Update(&sha, &contextLen, sizeof(contextLen));
|
||||
}
|
||||
if ((ret == 0) && (context != NULL)) {
|
||||
ret = wc_Shake256_Update(&sha, context, contextLen);
|
||||
}
|
||||
if (ret == 0) {
|
||||
ret = wc_Shake256_Update(&sha, out, ED448_SIG_SIZE/2);
|
||||
}
|
||||
if (ret == 0) {
|
||||
ret = wc_Shake256_Update(&sha, key->p, ED448_PUB_KEY_SIZE);
|
||||
}
|
||||
if (ret == 0) {
|
||||
ret = wc_Shake256_Update(&sha, in, inLen);
|
||||
}
|
||||
if (ret == 0) {
|
||||
ret = wc_Shake256_Final(&sha, hram, sizeof(hram));
|
||||
}
|
||||
wc_Shake256_Free(&sha);
|
||||
}
|
||||
}
|
||||
|
||||
if (ret == 0) {
|
||||
sc448_reduce(hram);
|
||||
sc448_muladd(out + (ED448_SIG_SIZE/2), hram, az, nonce);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* Sign the message using the ed448 private key.
|
||||
* Signature type is Ed448.
|
||||
*
|
||||
* in [in] Message to sign.
|
||||
* inLen [in] Length of the message in bytes.
|
||||
* out [in] Buffer to write signature into.
|
||||
* outLen [in/out] On in, size of buffer.
|
||||
* On out, the length of the signature in bytes.
|
||||
* key [in] Ed448 key to use when signing
|
||||
* context [in] Context of signing.
|
||||
* contextLen [in] Length of context in bytes.
|
||||
* returns BAD_FUNC_ARG when a parameter is NULL or contextLen is zero when and
|
||||
* context is not NULL or public key not set,
|
||||
* BUFFER_E when outLen is less than ED448_SIG_SIZE,
|
||||
* other -ve values when hash fails,
|
||||
* 0 otherwise.
|
||||
*/
|
||||
int wc_ed448_sign_msg(const byte* in, word32 inLen, byte* out, word32 *outLen,
|
||||
ed448_key* key, const byte* context, byte contextLen)
|
||||
{
|
||||
return ed448_sign_msg(in, inLen, out, outLen, key, Ed448, context,
|
||||
contextLen);
|
||||
}
|
||||
|
||||
/* Sign the hash using the ed448 private key.
|
||||
* Signature type is Ed448ph.
|
||||
*
|
||||
* hash [in] Hash of message to sign.
|
||||
* hashLen [in] Length of hash of message in bytes.
|
||||
* out [in] Buffer to write signature into.
|
||||
* outLen [in/out] On in, size of buffer.
|
||||
* On out, the length of the signature in bytes.
|
||||
* key [in] Ed448 key to use when signing
|
||||
* context [in] Context of signing.
|
||||
* contextLen [in] Length of context in bytes.
|
||||
* returns BAD_FUNC_ARG when a parameter is NULL or contextLen is zero when and
|
||||
* context is not NULL or public key not set,
|
||||
* BUFFER_E when outLen is less than ED448_SIG_SIZE,
|
||||
* other -ve values when hash fails,
|
||||
* 0 otherwise.
|
||||
*/
|
||||
int wc_ed448ph_sign_hash(const byte* hash, word32 hashLen, byte* out,
|
||||
word32 *outLen, ed448_key* key,
|
||||
const byte* context, byte contextLen)
|
||||
{
|
||||
return ed448_sign_msg(hash, hashLen, out, outLen, key, Ed448ph, context,
|
||||
contextLen);
|
||||
}
|
||||
|
||||
/* Sign the message using the ed448 private key.
|
||||
* Signature type is Ed448ph.
|
||||
*
|
||||
* in [in] Message to sign.
|
||||
* inLen [in] Length of the message to sign in bytes.
|
||||
* out [in] Buffer to write signature into.
|
||||
* outLen [in/out] On in, size of buffer.
|
||||
* On out, the length of the signature in bytes.
|
||||
* key [in] Ed448 key to use when signing
|
||||
* context [in] Context of signing.
|
||||
* contextLen [in] Length of context in bytes.
|
||||
* returns BAD_FUNC_ARG when a parameter is NULL or contextLen is zero when and
|
||||
* context is not NULL or public key not set,
|
||||
* BUFFER_E when outLen is less than ED448_SIG_SIZE,
|
||||
* other -ve values when hash fails,
|
||||
* 0 otherwise.
|
||||
*/
|
||||
int wc_ed448ph_sign_msg(const byte* in, word32 inLen, byte* out, word32 *outLen,
|
||||
ed448_key* key, const byte* context, byte contextLen)
|
||||
{
|
||||
int ret = 0;
|
||||
byte hash[64];
|
||||
|
||||
ret = wc_Shake256Hash(in, inLen, hash, sizeof(hash));
|
||||
if (ret == 0) {
|
||||
ret = wc_ed448ph_sign_hash(hash, sizeof(hash), out, outLen, key,
|
||||
context, contextLen);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
#endif /* HAVE_ED448_SIGN */
|
||||
|
||||
#ifdef HAVE_ED448_VERIFY
|
||||
|
||||
/* Verify the message using the ed448 public key.
|
||||
*
|
||||
* sig [in] Signature to verify.
|
||||
* sigLen [in] Size of signature in bytes.
|
||||
* msg [in] Message to verify.
|
||||
* msgLen [in] Length of the message in bytes.
|
||||
* key [in] Ed448 key to use to verify.
|
||||
* type [in] Type of signature to verify: Ed448 or Ed448ph
|
||||
* context [in] Context of verification.
|
||||
* contextLen [in] Length of context in bytes.
|
||||
* returns BAD_FUNC_ARG when a parameter is NULL or contextLen is zero when and
|
||||
* context is not NULL or public key not set,
|
||||
* BUFFER_E when sigLen is less than ED448_SIG_SIZE,
|
||||
* other -ve values when hash fails,
|
||||
* 0 otherwise.
|
||||
*/
|
||||
static int ed448_verify_msg(const byte* sig, word32 sigLen, const byte* msg,
|
||||
word32 msgLen, int* res, ed448_key* key,
|
||||
byte type, const byte* context, byte contextLen)
|
||||
{
|
||||
byte rcheck[ED448_KEY_SIZE];
|
||||
byte h[ED448_SIG_SIZE];
|
||||
ge448_p2 A;
|
||||
ge448_p2 R;
|
||||
int ret = 0;
|
||||
wc_Shake sha;
|
||||
|
||||
/* sanity check on arguments */
|
||||
if ((sig == NULL) || (msg == NULL) || (res == NULL) || (key == NULL) ||
|
||||
((context == NULL) && (contextLen != 0))) {
|
||||
ret = BAD_FUNC_ARG;
|
||||
}
|
||||
|
||||
if (ret == 0) {
|
||||
/* set verification failed by default */
|
||||
*res = 0;
|
||||
|
||||
/* check on basics needed to verify signature */
|
||||
if (sigLen != ED448_SIG_SIZE) {
|
||||
ret = BAD_FUNC_ARG;
|
||||
}
|
||||
}
|
||||
|
||||
/* uncompress A (public key), test if valid, and negate it */
|
||||
if ((ret == 0) && (ge448_from_bytes_negate_vartime(&A, key->p) != 0)) {
|
||||
ret = BAD_FUNC_ARG;
|
||||
}
|
||||
|
||||
if (ret == 0) {
|
||||
/* find H(R,A,M) and store it as h */
|
||||
ret = wc_InitShake256(&sha, NULL, INVALID_DEVID);
|
||||
if (ret == 0) {
|
||||
ret = wc_Shake256_Update(&sha, ed448Ctx, ED448CTX_SIZE);
|
||||
if (ret == 0) {
|
||||
ret = wc_Shake256_Update(&sha, &type, sizeof(type));
|
||||
}
|
||||
if (ret == 0) {
|
||||
ret = wc_Shake256_Update(&sha, &contextLen, sizeof(contextLen));
|
||||
}
|
||||
if ((ret == 0) && (context != NULL)) {
|
||||
ret = wc_Shake256_Update(&sha, context, contextLen);
|
||||
}
|
||||
if (ret == 0) {
|
||||
ret = wc_Shake256_Update(&sha, sig, ED448_SIG_SIZE/2);
|
||||
}
|
||||
if (ret == 0) {
|
||||
ret = wc_Shake256_Update(&sha, key->p, ED448_PUB_KEY_SIZE);
|
||||
}
|
||||
if (ret == 0) {
|
||||
ret = wc_Shake256_Update(&sha, msg, msgLen);
|
||||
}
|
||||
if (ret == 0) {
|
||||
ret = wc_Shake256_Final(&sha, h, sizeof(h));
|
||||
}
|
||||
wc_Shake256_Free(&sha);
|
||||
}
|
||||
}
|
||||
if (ret == 0) {
|
||||
sc448_reduce(h);
|
||||
|
||||
/* Uses a fast single-signature verification SB = R + H(R,A,M)A becomes
|
||||
* SB - H(R,A,M)A saving decompression of R
|
||||
*/
|
||||
ret = ge448_double_scalarmult_vartime(&R, h, &A,
|
||||
sig + (ED448_SIG_SIZE/2));
|
||||
}
|
||||
|
||||
if (ret == 0) {
|
||||
ge448_to_bytes(rcheck, &R);
|
||||
|
||||
/* comparison of R created to R in sig */
|
||||
if (ConstantCompare(rcheck, sig, ED448_SIG_SIZE/2) != 0) {
|
||||
ret = SIG_VERIFY_E;
|
||||
}
|
||||
else {
|
||||
/* set the verification status */
|
||||
*res = 1;
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* Verify the message using the ed448 public key.
|
||||
* Signature type is Ed448.
|
||||
*
|
||||
* sig [in] Signature to verify.
|
||||
* sigLen [in] Size of signature in bytes.
|
||||
* msg [in] Message to verify.
|
||||
* msgLen [in] Length of the message in bytes.
|
||||
* key [in] Ed448 key to use to verify.
|
||||
* context [in] Context of verification.
|
||||
* contextLen [in] Length of context in bytes.
|
||||
* returns BAD_FUNC_ARG when a parameter is NULL or contextLen is zero when and
|
||||
* context is not NULL or public key not set,
|
||||
* BUFFER_E when sigLen is less than ED448_SIG_SIZE,
|
||||
* other -ve values when hash fails,
|
||||
* 0 otherwise.
|
||||
*/
|
||||
int wc_ed448_verify_msg(const byte* sig, word32 sigLen, const byte* msg,
|
||||
word32 msgLen, int* res, ed448_key* key,
|
||||
const byte* context, byte contextLen)
|
||||
{
|
||||
return ed448_verify_msg(sig, sigLen, msg, msgLen, res, key, Ed448,
|
||||
context, contextLen);
|
||||
}
|
||||
|
||||
/* Verify the hash using the ed448 public key.
|
||||
* Signature type is Ed448ph.
|
||||
*
|
||||
* sig [in] Signature to verify.
|
||||
* sigLen [in] Size of signature in bytes.
|
||||
* hash [in] Hash of message to verify.
|
||||
* hashLen [in] Length of the hash in bytes.
|
||||
* key [in] Ed448 key to use to verify.
|
||||
* context [in] Context of verification.
|
||||
* contextLen [in] Length of context in bytes.
|
||||
* returns BAD_FUNC_ARG when a parameter is NULL or contextLen is zero when and
|
||||
* context is not NULL or public key not set,
|
||||
* BUFFER_E when sigLen is less than ED448_SIG_SIZE,
|
||||
* other -ve values when hash fails,
|
||||
* 0 otherwise.
|
||||
*/
|
||||
int wc_ed448ph_verify_hash(const byte* sig, word32 sigLen, const byte* hash,
|
||||
word32 hashLen, int* res, ed448_key* key,
|
||||
const byte* context, byte contextLen)
|
||||
{
|
||||
return ed448_verify_msg(sig, sigLen, hash, hashLen, res, key, Ed448ph,
|
||||
context, contextLen);
|
||||
}
|
||||
|
||||
/* Verify the message using the ed448 public key.
|
||||
* Signature type is Ed448ph.
|
||||
*
|
||||
* sig [in] Signature to verify.
|
||||
* sigLen [in] Size of signature in bytes.
|
||||
* msg [in] Message to verify.
|
||||
* msgLen [in] Length of the message in bytes.
|
||||
* key [in] Ed448 key to use to verify.
|
||||
* context [in] Context of verification.
|
||||
* contextLen [in] Length of context in bytes.
|
||||
* returns BAD_FUNC_ARG when a parameter is NULL or contextLen is zero when and
|
||||
* context is not NULL or public key not set,
|
||||
* BUFFER_E when sigLen is less than ED448_SIG_SIZE,
|
||||
* other -ve values when hash fails,
|
||||
* 0 otherwise.
|
||||
*/
|
||||
int wc_ed448ph_verify_msg(const byte* sig, word32 sigLen, const byte* msg,
|
||||
word32 msgLen, int* res, ed448_key* key,
|
||||
const byte* context, byte contextLen)
|
||||
{
|
||||
int ret = 0;
|
||||
byte hash[64];
|
||||
|
||||
ret = wc_Shake256Hash(msg, msgLen, hash, sizeof(hash));
|
||||
if (ret == 0) {
|
||||
ret = wc_ed448ph_verify_hash(sig, sigLen, hash, sizeof(hash), res, key,
|
||||
context, contextLen);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
#endif /* HAVE_ED448_VERIFY */
|
||||
|
||||
/* Initialize the ed448 private/public key.
|
||||
*
|
||||
* key [in] Ed448 key.
|
||||
* returns BAD_FUNC_ARG when key is NULL
|
||||
*/
|
||||
int wc_ed448_init(ed448_key* key)
|
||||
{
|
||||
int ret = 0;
|
||||
|
||||
if (key == NULL) {
|
||||
ret = BAD_FUNC_ARG;
|
||||
}
|
||||
else {
|
||||
XMEMSET(key, 0, sizeof(ed448_key));
|
||||
|
||||
fe448_init();
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
/* Clears the ed448 key data
|
||||
*
|
||||
* key [in] Ed448 key.
|
||||
*/
|
||||
void wc_ed448_free(ed448_key* key)
|
||||
{
|
||||
if (key != NULL) {
|
||||
ForceZero(key, sizeof(ed448_key));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#ifdef HAVE_ED448_KEY_EXPORT
|
||||
|
||||
/* Export the ed448 public key.
|
||||
*
|
||||
* key [in] Ed448 public key.
|
||||
* out [in] Array to hold public key.
|
||||
* outLen [in/out] On in, the number of bytes in array.
|
||||
* On out, the number bytes put into array.
|
||||
* returns BAD_FUNC_ARG when a parameter is NULL,
|
||||
* ECC_BAD_ARG_E when outLen is less than ED448_PUB_KEY_SIZE,
|
||||
* 0 otherwise.
|
||||
*/
|
||||
int wc_ed448_export_public(ed448_key* key, byte* out, word32* outLen)
|
||||
{
|
||||
int ret = 0;
|
||||
|
||||
/* sanity check on arguments */
|
||||
if ((key == NULL) || (out == NULL) || (outLen == NULL)) {
|
||||
ret = BAD_FUNC_ARG;
|
||||
}
|
||||
|
||||
if ((ret == 0) && (*outLen < ED448_PUB_KEY_SIZE)) {
|
||||
*outLen = ED448_PUB_KEY_SIZE;
|
||||
ret = BUFFER_E;
|
||||
}
|
||||
|
||||
if (ret == 0) {
|
||||
*outLen = ED448_PUB_KEY_SIZE;
|
||||
XMEMCPY(out, key->p, ED448_PUB_KEY_SIZE);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
#endif /* HAVE_ED448_KEY_EXPORT */
|
||||
|
||||
|
||||
#ifdef HAVE_ED448_KEY_IMPORT
|
||||
/* Import a compressed or uncompressed ed448 public key from a byte array.
|
||||
* Public key encoded in big-endian.
|
||||
*
|
||||
* in [in] Array holding public key.
|
||||
* inLen [in] Number of bytes of data in array.
|
||||
* key [in] Ed448 public key.
|
||||
* returns BAD_FUNC_ARG when a parameter is NULL or key format is not supported,
|
||||
* 0 otherwise.
|
||||
*/
|
||||
int wc_ed448_import_public(const byte* in, word32 inLen, ed448_key* key)
|
||||
{
|
||||
int ret = 0;
|
||||
|
||||
/* sanity check on arguments */
|
||||
if ((in == NULL) || (key == NULL)) {
|
||||
ret = BAD_FUNC_ARG;
|
||||
}
|
||||
|
||||
if (inLen < ED448_PUB_KEY_SIZE) {
|
||||
ret = BAD_FUNC_ARG;
|
||||
}
|
||||
|
||||
if (ret == 0) {
|
||||
/* compressed prefix according to draft
|
||||
* https://tools.ietf.org/html/draft-ietf-openpgp-rfc4880bis-06 */
|
||||
if (in[0] == 0x40 && inLen > ED448_PUB_KEY_SIZE) {
|
||||
/* key is stored in compressed format so just copy in */
|
||||
XMEMCPY(key->p, (in + 1), ED448_PUB_KEY_SIZE);
|
||||
key->pubKeySet = 1;
|
||||
}
|
||||
/* importing uncompressed public key */
|
||||
else if (in[0] == 0x04 && inLen > 2*ED448_PUB_KEY_SIZE) {
|
||||
/* pass in (x,y) and store compressed key */
|
||||
ret = ge448_compress_key(key->p, in+1, in+1+ED448_PUB_KEY_SIZE);
|
||||
if (ret == 0)
|
||||
key->pubKeySet = 1;
|
||||
}
|
||||
else if (inLen == ED448_PUB_KEY_SIZE) {
|
||||
/* if not specified compressed or uncompressed check key size
|
||||
* if key size is equal to compressed key size copy in key */
|
||||
XMEMCPY(key->p, in, ED448_PUB_KEY_SIZE);
|
||||
key->pubKeySet = 1;
|
||||
}
|
||||
else {
|
||||
/* bad public key format */
|
||||
ret = BAD_FUNC_ARG;
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
/* Import an ed448 private key from a byte array.
|
||||
*
|
||||
* priv [in] Array holding private key.
|
||||
* privSz [in] Number of bytes of data in array.
|
||||
* key [in] Ed448 private key.
|
||||
* returns BAD_FUNC_ARG when a parameter is NULL or privSz is less than
|
||||
* ED448_KEY_SIZE,
|
||||
* 0 otherwise.
|
||||
*/
|
||||
int wc_ed448_import_private_only(const byte* priv, word32 privSz,
|
||||
ed448_key* key)
|
||||
{
|
||||
int ret = 0;
|
||||
|
||||
/* sanity check on arguments */
|
||||
if ((priv == NULL) || (key == NULL)) {
|
||||
ret = BAD_FUNC_ARG;
|
||||
}
|
||||
|
||||
/* key size check */
|
||||
if ((ret == 0) && (privSz < ED448_KEY_SIZE)) {
|
||||
ret = BAD_FUNC_ARG;
|
||||
}
|
||||
|
||||
if (ret == 0) {
|
||||
XMEMCPY(key->k, priv, ED448_KEY_SIZE);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* Import an ed448 private and public keys from a byte arrays.
|
||||
*
|
||||
* priv [in] Array holding private key.
|
||||
* privSz [in] Number of bytes of data in private key array.
|
||||
* pub [in] Array holding private key.
|
||||
* pubSz [in] Number of bytes of data in public key array.
|
||||
* key [in] Ed448 private/public key.
|
||||
* returns BAD_FUNC_ARG when a parameter is NULL or privSz is less than
|
||||
* ED448_KEY_SIZE or pubSz is less than ED448_PUB_KEY_SIZE,
|
||||
* 0 otherwise.
|
||||
*/
|
||||
int wc_ed448_import_private_key(const byte* priv, word32 privSz,
|
||||
const byte* pub, word32 pubSz, ed448_key* key)
|
||||
{
|
||||
int ret = 0;
|
||||
|
||||
/* sanity check on arguments */
|
||||
if ((priv == NULL) || (pub == NULL) || (key == NULL)) {
|
||||
ret = BAD_FUNC_ARG;
|
||||
}
|
||||
|
||||
/* key size check */
|
||||
if ((ret == 0) && ((privSz < ED448_KEY_SIZE) ||
|
||||
(pubSz < ED448_PUB_KEY_SIZE))) {
|
||||
ret = BAD_FUNC_ARG;
|
||||
}
|
||||
|
||||
if (ret == 0) {
|
||||
/* import public key */
|
||||
ret = wc_ed448_import_public(pub, pubSz, key);
|
||||
}
|
||||
if (ret == 0) {
|
||||
/* make the private key (priv + pub) */
|
||||
XMEMCPY(key->k, priv, ED448_KEY_SIZE);
|
||||
XMEMCPY(key->k + ED448_KEY_SIZE, key->p, ED448_PUB_KEY_SIZE);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
#endif /* HAVE_ED448_KEY_IMPORT */
|
||||
|
||||
|
||||
#ifdef HAVE_ED448_KEY_EXPORT
|
||||
|
||||
/* Export the ed448 private key.
|
||||
*
|
||||
* key [in] Ed448 private key.
|
||||
* out [in] Array to hold private key.
|
||||
* outLen [in/out] On in, the number of bytes in array.
|
||||
* On out, the number bytes put into array.
|
||||
* returns BAD_FUNC_ARG when a parameter is NULL,
|
||||
* ECC_BAD_ARG_E when outLen is less than ED448_KEY_SIZE,
|
||||
* 0 otherwise.
|
||||
*/
|
||||
int wc_ed448_export_private_only(ed448_key* key, byte* out, word32* outLen)
|
||||
{
|
||||
int ret = 0;
|
||||
|
||||
/* sanity checks on arguments */
|
||||
if ((key == NULL) || (out == NULL) || (outLen == NULL)) {
|
||||
ret = BAD_FUNC_ARG;
|
||||
}
|
||||
|
||||
if ((ret == 0) && (*outLen < ED448_KEY_SIZE)) {
|
||||
*outLen = ED448_KEY_SIZE;
|
||||
ret = BUFFER_E;
|
||||
}
|
||||
|
||||
if (ret == 0) {
|
||||
*outLen = ED448_KEY_SIZE;
|
||||
XMEMCPY(out, key->k, ED448_KEY_SIZE);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* Export the ed448 private and public key.
|
||||
*
|
||||
* key [in] Ed448 private/public key.
|
||||
* out [in] Array to hold private and public key.
|
||||
* outLen [in/out] On in, the number of bytes in array.
|
||||
* On out, the number bytes put into array.
|
||||
* returns BAD_FUNC_ARG when a parameter is NULL,
|
||||
* BUFFER_E when outLen is less than ED448_PRV_KEY_SIZE,
|
||||
* 0 otherwise.
|
||||
*/
|
||||
int wc_ed448_export_private(ed448_key* key, byte* out, word32* outLen)
|
||||
{
|
||||
int ret = 0;
|
||||
|
||||
/* sanity checks on arguments */
|
||||
if ((key == NULL) || (out == NULL) || (outLen == NULL)) {
|
||||
ret = BAD_FUNC_ARG;
|
||||
}
|
||||
|
||||
if ((ret == 0) && (*outLen < ED448_PRV_KEY_SIZE)) {
|
||||
*outLen = ED448_PRV_KEY_SIZE;
|
||||
ret = BUFFER_E;
|
||||
}
|
||||
|
||||
if (ret == 0) {
|
||||
*outLen = ED448_PRV_KEY_SIZE;
|
||||
XMEMCPY(out, key->k, ED448_PRV_KEY_SIZE);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* Export the ed448 private and public key.
|
||||
*
|
||||
* key [in] Ed448 private/public key.
|
||||
* priv [in] Array to hold private key.
|
||||
* privSz [in/out] On in, the number of bytes in private key array.
|
||||
* pub [in] Array to hold public key.
|
||||
* pubSz [in/out] On in, the number of bytes in public key array.
|
||||
* On out, the number bytes put into array.
|
||||
* returns BAD_FUNC_ARG when a parameter is NULL,
|
||||
* BUFFER_E when privSz is less than ED448_PRV_KEY_SIZE or pubSz is less
|
||||
* than ED448_PUB_KEY_SIZE,
|
||||
* 0 otherwise.
|
||||
*/
|
||||
int wc_ed448_export_key(ed448_key* key, byte* priv, word32 *privSz,
|
||||
byte* pub, word32 *pubSz)
|
||||
{
|
||||
int ret = 0;
|
||||
|
||||
/* export 'full' private part */
|
||||
ret = wc_ed448_export_private(key, priv, privSz);
|
||||
if (ret == 0) {
|
||||
/* export public part */
|
||||
ret = wc_ed448_export_public(key, pub, pubSz);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
#endif /* HAVE_ED448_KEY_EXPORT */
|
||||
|
||||
/* Check the public key of the ed448 key matches the private key.
|
||||
*
|
||||
* key [in] Ed448 private/public key.
|
||||
* returns BAD_FUNC_ARG when key is NULL,
|
||||
* PUBLIC_KEY_E when the public key is not set or doesn't match,
|
||||
* other -ve value on hash failure,
|
||||
* 0 otherwise.
|
||||
*/
|
||||
int wc_ed448_check_key(ed448_key* key)
|
||||
{
|
||||
int ret = 0;
|
||||
unsigned char pubKey[ED448_PUB_KEY_SIZE];
|
||||
|
||||
if (key == NULL) {
|
||||
ret = BAD_FUNC_ARG;
|
||||
}
|
||||
|
||||
if (!key->pubKeySet) {
|
||||
ret = PUBLIC_KEY_E;
|
||||
}
|
||||
if (ret == 0) {
|
||||
ret = wc_ed448_make_public(key, pubKey, sizeof(pubKey));
|
||||
}
|
||||
if ((ret == 0) && (XMEMCMP(pubKey, key->p, ED448_PUB_KEY_SIZE) != 0)) {
|
||||
ret = PUBLIC_KEY_E;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* Returns the size of an ed448 private key.
|
||||
*
|
||||
* key [in] Ed448 private/public key.
|
||||
* returns BAD_FUNC_ARG when key is NULL,
|
||||
* ED448_KEY_SIZE otherwise.
|
||||
*/
|
||||
int wc_ed448_size(ed448_key* key)
|
||||
{
|
||||
int ret = ED448_KEY_SIZE;
|
||||
|
||||
if (key == NULL) {
|
||||
ret = BAD_FUNC_ARG;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* Returns the size of an ed448 private plus public key.
|
||||
*
|
||||
* key [in] Ed448 private/public key.
|
||||
* returns BAD_FUNC_ARG when key is NULL,
|
||||
* ED448_PRV_KEY_SIZE otherwise.
|
||||
*/
|
||||
int wc_ed448_priv_size(ed448_key* key)
|
||||
{
|
||||
int ret = ED448_PRV_KEY_SIZE;
|
||||
|
||||
if (key == NULL) {
|
||||
ret = BAD_FUNC_ARG;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* Returns the size of an ed448 public key.
|
||||
*
|
||||
* key [in] Ed448 private/public key.
|
||||
* returns BAD_FUNC_ARG when key is NULL,
|
||||
* ED448_PUB_KEY_SIZE otherwise.
|
||||
*/
|
||||
int wc_ed448_pub_size(ed448_key* key)
|
||||
{
|
||||
int ret = ED448_PUB_KEY_SIZE;
|
||||
|
||||
if (key == NULL) {
|
||||
ret = BAD_FUNC_ARG;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* Returns the size of an ed448 signature.
|
||||
*
|
||||
* key [in] Ed448 private/public key.
|
||||
* returns BAD_FUNC_ARG when key is NULL,
|
||||
* ED448_SIG_SIZE otherwise.
|
||||
*/
|
||||
int wc_ed448_sig_size(ed448_key* key)
|
||||
{
|
||||
int ret = ED448_SIG_SIZE;
|
||||
|
||||
if (key == NULL) {
|
||||
ret = BAD_FUNC_ARG;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
#endif /* HAVE_ED448 */
|
||||
|
@ -1,533 +0,0 @@
|
||||
/* error.c
|
||||
*
|
||||
* Copyright (C) 2006-2020 wolfSSL Inc.
|
||||
*
|
||||
* This file is part of wolfSSL.
|
||||
*
|
||||
* wolfSSL is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* wolfSSL is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA
|
||||
*/
|
||||
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
#endif
|
||||
|
||||
#include <wolfssl/wolfcrypt/settings.h>
|
||||
|
||||
#include <wolfssl/wolfcrypt/error-crypt.h>
|
||||
|
||||
#ifdef _MSC_VER
|
||||
/* 4996 warning to use MS extensions e.g., strcpy_s instead of XSTRNCPY */
|
||||
#pragma warning(disable: 4996)
|
||||
#endif
|
||||
|
||||
#ifndef NO_ERROR_STRINGS
|
||||
const char* wc_GetErrorString(int error)
|
||||
{
|
||||
switch (error) {
|
||||
|
||||
case OPEN_RAN_E :
|
||||
return "opening random device error";
|
||||
|
||||
case READ_RAN_E :
|
||||
return "reading random device error";
|
||||
|
||||
case WINCRYPT_E :
|
||||
return "windows crypt init error";
|
||||
|
||||
case CRYPTGEN_E :
|
||||
return "windows crypt generation error";
|
||||
|
||||
case RAN_BLOCK_E :
|
||||
return "random device read would block error";
|
||||
|
||||
case BAD_MUTEX_E :
|
||||
return "Bad mutex, operation failed";
|
||||
|
||||
case WC_TIMEOUT_E:
|
||||
return "Timeout error";
|
||||
|
||||
case WC_PENDING_E:
|
||||
return "wolfCrypt Operation Pending (would block / eagain) error";
|
||||
|
||||
case WC_NOT_PENDING_E:
|
||||
return "wolfCrypt operation not pending error";
|
||||
|
||||
case MP_INIT_E :
|
||||
return "mp_init error state";
|
||||
|
||||
case MP_READ_E :
|
||||
return "mp_read error state";
|
||||
|
||||
case MP_EXPTMOD_E :
|
||||
return "mp_exptmod error state";
|
||||
|
||||
case MP_TO_E :
|
||||
return "mp_to_xxx error state, can't convert";
|
||||
|
||||
case MP_SUB_E :
|
||||
return "mp_sub error state, can't subtract";
|
||||
|
||||
case MP_ADD_E :
|
||||
return "mp_add error state, can't add";
|
||||
|
||||
case MP_MUL_E :
|
||||
return "mp_mul error state, can't multiply";
|
||||
|
||||
case MP_MULMOD_E :
|
||||
return "mp_mulmod error state, can't multiply mod";
|
||||
|
||||
case MP_MOD_E :
|
||||
return "mp_mod error state, can't mod";
|
||||
|
||||
case MP_INVMOD_E :
|
||||
return "mp_invmod error state, can't inv mod";
|
||||
|
||||
case MP_CMP_E :
|
||||
return "mp_cmp error state";
|
||||
|
||||
case MP_ZERO_E :
|
||||
return "mp zero result, not expected";
|
||||
|
||||
case MEMORY_E :
|
||||
return "out of memory error";
|
||||
|
||||
case VAR_STATE_CHANGE_E :
|
||||
return "Variable state modified by different thread";
|
||||
|
||||
case RSA_WRONG_TYPE_E :
|
||||
return "RSA wrong block type for RSA function";
|
||||
|
||||
case RSA_BUFFER_E :
|
||||
return "RSA buffer error, output too small or input too big";
|
||||
|
||||
case BUFFER_E :
|
||||
return "Buffer error, output too small or input too big";
|
||||
|
||||
case ALGO_ID_E :
|
||||
return "Setting Cert AlgoID error";
|
||||
|
||||
case PUBLIC_KEY_E :
|
||||
return "Setting Cert Public Key error";
|
||||
|
||||
case DATE_E :
|
||||
return "Setting Cert Date validity error";
|
||||
|
||||
case SUBJECT_E :
|
||||
return "Setting Cert Subject name error";
|
||||
|
||||
case ISSUER_E :
|
||||
return "Setting Cert Issuer name error";
|
||||
|
||||
case CA_TRUE_E :
|
||||
return "Setting basic constraint CA true error";
|
||||
|
||||
case EXTENSIONS_E :
|
||||
return "Setting extensions error";
|
||||
|
||||
case ASN_PARSE_E :
|
||||
return "ASN parsing error, invalid input";
|
||||
|
||||
case ASN_VERSION_E :
|
||||
return "ASN version error, invalid number";
|
||||
|
||||
case ASN_GETINT_E :
|
||||
return "ASN get big int error, invalid data";
|
||||
|
||||
case ASN_RSA_KEY_E :
|
||||
return "ASN key init error, invalid input";
|
||||
|
||||
case ASN_OBJECT_ID_E :
|
||||
return "ASN object id error, invalid id";
|
||||
|
||||
case ASN_TAG_NULL_E :
|
||||
return "ASN tag error, not null";
|
||||
|
||||
case ASN_EXPECT_0_E :
|
||||
return "ASN expect error, not zero";
|
||||
|
||||
case ASN_BITSTR_E :
|
||||
return "ASN bit string error, wrong id";
|
||||
|
||||
case ASN_UNKNOWN_OID_E :
|
||||
return "ASN oid error, unknown sum id";
|
||||
|
||||
case ASN_DATE_SZ_E :
|
||||
return "ASN date error, bad size";
|
||||
|
||||
case ASN_BEFORE_DATE_E :
|
||||
return "ASN date error, current date before";
|
||||
|
||||
case ASN_AFTER_DATE_E :
|
||||
return "ASN date error, current date after";
|
||||
|
||||
case ASN_SIG_OID_E :
|
||||
return "ASN signature error, mismatched oid";
|
||||
|
||||
case ASN_TIME_E :
|
||||
return "ASN time error, unknown time type";
|
||||
|
||||
case ASN_INPUT_E :
|
||||
return "ASN input error, not enough data";
|
||||
|
||||
case ASN_SIG_CONFIRM_E :
|
||||
return "ASN sig error, confirm failure";
|
||||
|
||||
case ASN_SIG_HASH_E :
|
||||
return "ASN sig error, unsupported hash type";
|
||||
|
||||
case ASN_SIG_KEY_E :
|
||||
return "ASN sig error, unsupported key type";
|
||||
|
||||
case ASN_DH_KEY_E :
|
||||
return "ASN key init error, invalid input";
|
||||
|
||||
case ASN_NTRU_KEY_E :
|
||||
return "ASN NTRU key decode error, invalid input";
|
||||
|
||||
case ASN_CRIT_EXT_E:
|
||||
return "X.509 Critical extension ignored or invalid";
|
||||
|
||||
case ASN_ALT_NAME_E:
|
||||
return "ASN alternate name error";
|
||||
|
||||
case ECC_BAD_ARG_E :
|
||||
return "ECC input argument wrong type, invalid input";
|
||||
|
||||
case ASN_ECC_KEY_E :
|
||||
return "ECC ASN1 bad key data, invalid input";
|
||||
|
||||
case ECC_CURVE_OID_E :
|
||||
return "ECC curve sum OID unsupported, invalid input";
|
||||
|
||||
case BAD_FUNC_ARG :
|
||||
return "Bad function argument";
|
||||
|
||||
case NOT_COMPILED_IN :
|
||||
return "Feature not compiled in";
|
||||
|
||||
case UNICODE_SIZE_E :
|
||||
return "Unicode password too big";
|
||||
|
||||
case NO_PASSWORD :
|
||||
return "No password provided by user";
|
||||
|
||||
case ALT_NAME_E :
|
||||
return "Alt Name problem, too big";
|
||||
|
||||
case AES_GCM_AUTH_E:
|
||||
return "AES-GCM Authentication check fail";
|
||||
|
||||
case AES_CCM_AUTH_E:
|
||||
return "AES-CCM Authentication check fail";
|
||||
|
||||
case ASYNC_INIT_E:
|
||||
return "Async Init error";
|
||||
|
||||
case COMPRESS_INIT_E:
|
||||
return "Compress Init error";
|
||||
|
||||
case COMPRESS_E:
|
||||
return "Compress error";
|
||||
|
||||
case DECOMPRESS_INIT_E:
|
||||
return "DeCompress Init error";
|
||||
|
||||
case DECOMPRESS_E:
|
||||
return "DeCompress error";
|
||||
|
||||
case BAD_ALIGN_E:
|
||||
return "Bad alignment error, no alloc help";
|
||||
|
||||
case ASN_NO_SIGNER_E :
|
||||
return "ASN no signer error to confirm failure";
|
||||
|
||||
case ASN_CRL_CONFIRM_E :
|
||||
return "ASN CRL sig error, confirm failure";
|
||||
|
||||
case ASN_CRL_NO_SIGNER_E :
|
||||
return "ASN CRL no signer error to confirm failure";
|
||||
|
||||
case ASN_OCSP_CONFIRM_E :
|
||||
return "ASN OCSP sig error, confirm failure";
|
||||
|
||||
case ASN_NO_PEM_HEADER:
|
||||
return "ASN no PEM Header Error";
|
||||
|
||||
case BAD_STATE_E:
|
||||
return "Bad state operation";
|
||||
|
||||
case BAD_PADDING_E:
|
||||
return "Bad padding, message wrong length";
|
||||
|
||||
case REQ_ATTRIBUTE_E:
|
||||
return "Setting cert request attributes error";
|
||||
|
||||
case PKCS7_OID_E:
|
||||
return "PKCS#7 error: mismatched OID value";
|
||||
|
||||
case PKCS7_RECIP_E:
|
||||
return "PKCS#7 error: no matching recipient found";
|
||||
|
||||
case WC_PKCS7_WANT_READ_E:
|
||||
return "PKCS#7 operations wants more input, call again";
|
||||
|
||||
case FIPS_NOT_ALLOWED_E:
|
||||
return "FIPS mode not allowed error";
|
||||
|
||||
case ASN_NAME_INVALID_E:
|
||||
return "Name Constraint error";
|
||||
|
||||
case RNG_FAILURE_E:
|
||||
return "Random Number Generator failed";
|
||||
|
||||
case HMAC_MIN_KEYLEN_E:
|
||||
return "FIPS Mode HMAC Minimum Key Length error";
|
||||
|
||||
case RSA_PAD_E:
|
||||
return "Rsa Padding error";
|
||||
|
||||
case LENGTH_ONLY_E:
|
||||
return "Output length only set, not for other use error";
|
||||
|
||||
case IN_CORE_FIPS_E:
|
||||
return "In Core Integrity check FIPS error";
|
||||
|
||||
case AES_KAT_FIPS_E:
|
||||
return "AES Known Answer Test check FIPS error";
|
||||
|
||||
case DES3_KAT_FIPS_E:
|
||||
return "DES3 Known Answer Test check FIPS error";
|
||||
|
||||
case HMAC_KAT_FIPS_E:
|
||||
return "HMAC Known Answer Test check FIPS error";
|
||||
|
||||
case RSA_KAT_FIPS_E:
|
||||
return "RSA Known Answer Test check FIPS error";
|
||||
|
||||
case DRBG_KAT_FIPS_E:
|
||||
return "DRBG Known Answer Test check FIPS error";
|
||||
|
||||
case DRBG_CONT_FIPS_E:
|
||||
return "DRBG Continuous Test FIPS error";
|
||||
|
||||
case AESGCM_KAT_FIPS_E:
|
||||
return "AESGCM Known Answer Test check FIPS error";
|
||||
|
||||
case THREAD_STORE_KEY_E:
|
||||
return "Thread Storage Key Create error";
|
||||
|
||||
case THREAD_STORE_SET_E:
|
||||
return "Thread Storage Set error";
|
||||
|
||||
case MAC_CMP_FAILED_E:
|
||||
return "MAC comparison failed";
|
||||
|
||||
case IS_POINT_E:
|
||||
return "ECC is point on curve failed";
|
||||
|
||||
case ECC_INF_E:
|
||||
return " ECC point at infinity error";
|
||||
|
||||
case ECC_OUT_OF_RANGE_E:
|
||||
return " ECC Qx or Qy out of range error";
|
||||
|
||||
case ECC_PRIV_KEY_E:
|
||||
return " ECC private key is not valid error";
|
||||
|
||||
case SRP_CALL_ORDER_E:
|
||||
return "SRP function called in the wrong order error";
|
||||
|
||||
case SRP_VERIFY_E:
|
||||
return "SRP proof verification error";
|
||||
|
||||
case SRP_BAD_KEY_E:
|
||||
return "SRP bad key values error";
|
||||
|
||||
case ASN_NO_SKID:
|
||||
return "ASN no Subject Key Identifier found error";
|
||||
|
||||
case ASN_NO_AKID:
|
||||
return "ASN no Authority Key Identifier found error";
|
||||
|
||||
case ASN_NO_KEYUSAGE:
|
||||
return "ASN no Key Usage found error";
|
||||
|
||||
case SKID_E:
|
||||
return "Setting Subject Key Identifier error";
|
||||
|
||||
case AKID_E:
|
||||
return "Setting Authority Key Identifier error";
|
||||
|
||||
case KEYUSAGE_E:
|
||||
return "Key Usage value error";
|
||||
|
||||
case EXTKEYUSAGE_E:
|
||||
return "Extended Key Usage value error";
|
||||
|
||||
case CERTPOLICIES_E:
|
||||
return "Setting Certificate Policies error";
|
||||
|
||||
case WC_INIT_E:
|
||||
return "wolfCrypt Initialize Failure error";
|
||||
|
||||
case SIG_VERIFY_E:
|
||||
return "Signature verify error";
|
||||
|
||||
case BAD_COND_E:
|
||||
return "Bad condition variable operation error";
|
||||
|
||||
case SIG_TYPE_E:
|
||||
return "Signature type not enabled/available";
|
||||
|
||||
case HASH_TYPE_E:
|
||||
return "Hash type not enabled/available";
|
||||
|
||||
case WC_KEY_SIZE_E:
|
||||
return "Key size error, either too small or large";
|
||||
|
||||
case ASN_COUNTRY_SIZE_E:
|
||||
return "Country code size error, either too small or large";
|
||||
|
||||
case MISSING_RNG_E:
|
||||
return "RNG required but not provided";
|
||||
|
||||
case ASN_PATHLEN_SIZE_E:
|
||||
return "ASN CA path length value too large error";
|
||||
|
||||
case ASN_PATHLEN_INV_E:
|
||||
return "ASN CA path length larger than signer error";
|
||||
|
||||
case BAD_KEYWRAP_ALG_E:
|
||||
return "Unsupported key wrap algorithm error";
|
||||
|
||||
case BAD_KEYWRAP_IV_E:
|
||||
return "Decrypted AES key wrap IV does not match expected";
|
||||
|
||||
case WC_CLEANUP_E:
|
||||
return "wolfcrypt cleanup failed";
|
||||
|
||||
case ECC_CDH_KAT_FIPS_E:
|
||||
return "wolfcrypt FIPS ECC CDH Known Answer Test Failure";
|
||||
|
||||
case DH_CHECK_PUB_E:
|
||||
return "DH Check Public Key failure";
|
||||
|
||||
case BAD_PATH_ERROR:
|
||||
return "Bad path for opendir error";
|
||||
|
||||
case ASYNC_OP_E:
|
||||
return "Async operation error";
|
||||
|
||||
case BAD_OCSP_RESPONDER:
|
||||
return "Invalid OCSP Responder, missing specific key usage extensions";
|
||||
|
||||
case ECC_PRIVATEONLY_E:
|
||||
return "Invalid use of private only ECC key";
|
||||
|
||||
case WC_HW_E:
|
||||
return "Error with hardware crypto use";
|
||||
|
||||
case WC_HW_WAIT_E:
|
||||
return "Hardware waiting on resource";
|
||||
|
||||
case PSS_SALTLEN_E:
|
||||
return "PSS - Length of salt is too big for hash algorithm";
|
||||
|
||||
case PRIME_GEN_E:
|
||||
return "Unable to find a prime for RSA key";
|
||||
|
||||
case BER_INDEF_E:
|
||||
return "Unable to decode an indefinite length encoded message";
|
||||
|
||||
case RSA_OUT_OF_RANGE_E:
|
||||
return "Ciphertext to decrypt is out of range";
|
||||
|
||||
case RSAPSS_PAT_FIPS_E:
|
||||
return "wolfcrypt FIPS RSA-PSS Pairwise Agreement Test Failure";
|
||||
|
||||
case ECDSA_PAT_FIPS_E:
|
||||
return "wolfcrypt FIPS ECDSA Pairwise Agreement Test Failure";
|
||||
|
||||
case DH_KAT_FIPS_E:
|
||||
return "wolfcrypt FIPS DH Known Answer Test Failure";
|
||||
|
||||
case AESCCM_KAT_FIPS_E:
|
||||
return "AESCCM Known Answer Test check FIPS error";
|
||||
|
||||
case SHA3_KAT_FIPS_E:
|
||||
return "SHA-3 Known Answer Test check FIPS error";
|
||||
|
||||
case ECDHE_KAT_FIPS_E:
|
||||
return "wolfcrypt FIPS ECDHE Known Answer Test Failure";
|
||||
|
||||
case AES_GCM_OVERFLOW_E:
|
||||
return "AES-GCM invocation counter overflow";
|
||||
|
||||
case AES_CCM_OVERFLOW_E:
|
||||
return "AES-CCM invocation counter overflow";
|
||||
|
||||
case RSA_KEY_PAIR_E:
|
||||
return "RSA Key Pair-Wise Consistency check fail";
|
||||
|
||||
case DH_CHECK_PRIV_E:
|
||||
return "DH Check Private Key failure";
|
||||
|
||||
case WC_AFALG_SOCK_E:
|
||||
return "AF_ALG socket error";
|
||||
|
||||
case WC_DEVCRYPTO_E:
|
||||
return "Error with /dev/crypto";
|
||||
|
||||
case ZLIB_INIT_ERROR:
|
||||
return "zlib init error";
|
||||
|
||||
case ZLIB_COMPRESS_ERROR:
|
||||
return "zlib compress error";
|
||||
|
||||
case ZLIB_DECOMPRESS_ERROR:
|
||||
return "zlib decompress error";
|
||||
|
||||
case PKCS7_NO_SIGNER_E:
|
||||
return "No signer in PKCS#7 signed data";
|
||||
|
||||
case CRYPTOCB_UNAVAILABLE:
|
||||
return "Crypto callback unavailable";
|
||||
|
||||
case PKCS7_SIGNEEDS_CHECK:
|
||||
return "Signature found but no certificate to verify";
|
||||
|
||||
case PSS_SALTLEN_RECOVER_E:
|
||||
return "PSS - Salt length unable to be recovered";
|
||||
|
||||
case CHACHA_POLY_OVERFLOW:
|
||||
return "wolfcrypt - ChaCha20_Poly1305 limit overflow 4GB";
|
||||
|
||||
case ASN_SELF_SIGNED_E:
|
||||
return "ASN self-signed certificate error";
|
||||
|
||||
default:
|
||||
return "unknown error number";
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
void wc_ErrorString(int error, char* buffer)
|
||||
{
|
||||
XSTRNCPY(buffer, wc_GetErrorString(error), WOLFSSL_MAX_ERROR_SZ);
|
||||
buffer[WOLFSSL_MAX_ERROR_SZ-1] = 0;
|
||||
}
|
||||
#endif /* !NO_ERROR_STRINGS */
|
||||
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -1,611 +0,0 @@
|
||||
/* fe_low_mem.c
|
||||
*
|
||||
* Copyright (C) 2006-2020 wolfSSL Inc.
|
||||
*
|
||||
* This file is part of wolfSSL.
|
||||
*
|
||||
* wolfSSL is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* wolfSSL is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA
|
||||
*/
|
||||
|
||||
|
||||
/* Based from Daniel Beer's public domain work. */
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
#endif
|
||||
|
||||
#include <wolfssl/wolfcrypt/settings.h>
|
||||
|
||||
#if defined(HAVE_CURVE25519) || defined(HAVE_ED25519)
|
||||
#if defined(CURVE25519_SMALL) || defined(ED25519_SMALL) /* use slower code that takes less memory */
|
||||
|
||||
#include <wolfssl/wolfcrypt/fe_operations.h>
|
||||
|
||||
#ifdef NO_INLINE
|
||||
#include <wolfssl/wolfcrypt/misc.h>
|
||||
#else
|
||||
#define WOLFSSL_MISC_INCLUDED
|
||||
#include <wolfcrypt/src/misc.c>
|
||||
#endif
|
||||
|
||||
void fprime_copy(byte *x, const byte *a)
|
||||
{
|
||||
int i;
|
||||
for (i = 0; i < F25519_SIZE; i++)
|
||||
x[i] = a[i];
|
||||
}
|
||||
|
||||
|
||||
void lm_copy(byte* x, const byte* a)
|
||||
{
|
||||
int i;
|
||||
for (i = 0; i < F25519_SIZE; i++)
|
||||
x[i] = a[i];
|
||||
}
|
||||
|
||||
#if ((defined(HAVE_CURVE25519) && !defined(CURVE25519_SMALL)) || \
|
||||
(defined(HAVE_ED25519) && !defined(ED25519_SMALL))) && \
|
||||
!defined(FREESCALE_LTC_ECC)
|
||||
/* to be Complementary to fe_low_mem.c */
|
||||
#else
|
||||
void fe_init(void)
|
||||
{
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef CURVE25519_SMALL
|
||||
|
||||
/* Double an X-coordinate */
|
||||
static void xc_double(byte *x3, byte *z3,
|
||||
const byte *x1, const byte *z1)
|
||||
{
|
||||
/* Explicit formulas database: dbl-1987-m
|
||||
*
|
||||
* source 1987 Montgomery "Speeding the Pollard and elliptic
|
||||
* curve methods of factorization", page 261, fourth display
|
||||
* compute X3 = (X1^2-Z1^2)^2
|
||||
* compute Z3 = 4 X1 Z1 (X1^2 + a X1 Z1 + Z1^2)
|
||||
*/
|
||||
byte x1sq[F25519_SIZE];
|
||||
byte z1sq[F25519_SIZE];
|
||||
byte x1z1[F25519_SIZE];
|
||||
byte a[F25519_SIZE];
|
||||
|
||||
fe_mul__distinct(x1sq, x1, x1);
|
||||
fe_mul__distinct(z1sq, z1, z1);
|
||||
fe_mul__distinct(x1z1, x1, z1);
|
||||
|
||||
lm_sub(a, x1sq, z1sq);
|
||||
fe_mul__distinct(x3, a, a);
|
||||
|
||||
fe_mul_c(a, x1z1, 486662);
|
||||
lm_add(a, x1sq, a);
|
||||
lm_add(a, z1sq, a);
|
||||
fe_mul__distinct(x1sq, x1z1, a);
|
||||
fe_mul_c(z3, x1sq, 4);
|
||||
}
|
||||
|
||||
|
||||
/* Differential addition */
|
||||
static void xc_diffadd(byte *x5, byte *z5,
|
||||
const byte *x1, const byte *z1,
|
||||
const byte *x2, const byte *z2,
|
||||
const byte *x3, const byte *z3)
|
||||
{
|
||||
/* Explicit formulas database: dbl-1987-m3
|
||||
*
|
||||
* source 1987 Montgomery "Speeding the Pollard and elliptic curve
|
||||
* methods of factorization", page 261, fifth display, plus
|
||||
* common-subexpression elimination
|
||||
* compute A = X2+Z2
|
||||
* compute B = X2-Z2
|
||||
* compute C = X3+Z3
|
||||
* compute D = X3-Z3
|
||||
* compute DA = D A
|
||||
* compute CB = C B
|
||||
* compute X5 = Z1(DA+CB)^2
|
||||
* compute Z5 = X1(DA-CB)^2
|
||||
*/
|
||||
byte da[F25519_SIZE];
|
||||
byte cb[F25519_SIZE];
|
||||
byte a[F25519_SIZE];
|
||||
byte b[F25519_SIZE];
|
||||
|
||||
lm_add(a, x2, z2);
|
||||
lm_sub(b, x3, z3); /* D */
|
||||
fe_mul__distinct(da, a, b);
|
||||
|
||||
lm_sub(b, x2, z2);
|
||||
lm_add(a, x3, z3); /* C */
|
||||
fe_mul__distinct(cb, a, b);
|
||||
|
||||
lm_add(a, da, cb);
|
||||
fe_mul__distinct(b, a, a);
|
||||
fe_mul__distinct(x5, z1, b);
|
||||
|
||||
lm_sub(a, da, cb);
|
||||
fe_mul__distinct(b, a, a);
|
||||
fe_mul__distinct(z5, x1, b);
|
||||
}
|
||||
|
||||
#ifndef FREESCALE_LTC_ECC
|
||||
int curve25519(byte *result, const byte *e, const byte *q)
|
||||
{
|
||||
/* Current point: P_m */
|
||||
byte xm[F25519_SIZE];
|
||||
byte zm[F25519_SIZE] = {1};
|
||||
|
||||
/* Predecessor: P_(m-1) */
|
||||
byte xm1[F25519_SIZE] = {1};
|
||||
byte zm1[F25519_SIZE] = {0};
|
||||
|
||||
int i;
|
||||
|
||||
/* Note: bit 254 is assumed to be 1 */
|
||||
lm_copy(xm, q);
|
||||
|
||||
for (i = 253; i >= 0; i--) {
|
||||
const int bit = (e[i >> 3] >> (i & 7)) & 1;
|
||||
byte xms[F25519_SIZE];
|
||||
byte zms[F25519_SIZE];
|
||||
|
||||
/* From P_m and P_(m-1), compute P_(2m) and P_(2m-1) */
|
||||
xc_diffadd(xm1, zm1, q, f25519_one, xm, zm, xm1, zm1);
|
||||
xc_double(xm, zm, xm, zm);
|
||||
|
||||
/* Compute P_(2m+1) */
|
||||
xc_diffadd(xms, zms, xm1, zm1, xm, zm, q, f25519_one);
|
||||
|
||||
/* Select:
|
||||
* bit = 1 --> (P_(2m+1), P_(2m))
|
||||
* bit = 0 --> (P_(2m), P_(2m-1))
|
||||
*/
|
||||
fe_select(xm1, xm1, xm, bit);
|
||||
fe_select(zm1, zm1, zm, bit);
|
||||
fe_select(xm, xm, xms, bit);
|
||||
fe_select(zm, zm, zms, bit);
|
||||
}
|
||||
|
||||
/* Freeze out of projective coordinates */
|
||||
fe_inv__distinct(zm1, zm);
|
||||
fe_mul__distinct(result, zm1, xm);
|
||||
fe_normalize(result);
|
||||
return 0;
|
||||
}
|
||||
#endif /* !FREESCALE_LTC_ECC */
|
||||
#endif /* CURVE25519_SMALL */
|
||||
|
||||
|
||||
static void raw_add(byte *x, const byte *p)
|
||||
{
|
||||
word16 c = 0;
|
||||
int i;
|
||||
|
||||
for (i = 0; i < F25519_SIZE; i++) {
|
||||
c += ((word16)x[i]) + ((word16)p[i]);
|
||||
x[i] = (byte)c;
|
||||
c >>= 8;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void raw_try_sub(byte *x, const byte *p)
|
||||
{
|
||||
byte minusp[F25519_SIZE];
|
||||
word16 c = 0;
|
||||
int i;
|
||||
|
||||
for (i = 0; i < F25519_SIZE; i++) {
|
||||
c = ((word16)x[i]) - ((word16)p[i]) - c;
|
||||
minusp[i] = (byte)c;
|
||||
c = (c >> 8) & 1;
|
||||
}
|
||||
|
||||
fprime_select(x, minusp, x, (byte)c);
|
||||
}
|
||||
|
||||
|
||||
static int prime_msb(const byte *p)
|
||||
{
|
||||
int i;
|
||||
byte x;
|
||||
int shift = 1;
|
||||
int z = F25519_SIZE - 1;
|
||||
|
||||
/*
|
||||
Test for any hot bits.
|
||||
As soon as one instance is encountered set shift to 0.
|
||||
*/
|
||||
for (i = F25519_SIZE - 1; i >= 0; i--) {
|
||||
shift &= ((shift ^ ((-p[i] | p[i]) >> 7)) & 1);
|
||||
z -= shift;
|
||||
}
|
||||
x = p[z];
|
||||
z <<= 3;
|
||||
shift = 1;
|
||||
for (i = 0; i < 8; i++) {
|
||||
shift &= ((-(x >> i) | (x >> i)) >> (7 - i) & 1);
|
||||
z += shift;
|
||||
}
|
||||
|
||||
return z - 1;
|
||||
}
|
||||
|
||||
|
||||
void fprime_select(byte *dst, const byte *zero, const byte *one, byte condition)
|
||||
{
|
||||
const byte mask = -condition;
|
||||
int i;
|
||||
|
||||
for (i = 0; i < F25519_SIZE; i++)
|
||||
dst[i] = zero[i] ^ (mask & (one[i] ^ zero[i]));
|
||||
}
|
||||
|
||||
|
||||
void fprime_add(byte *r, const byte *a, const byte *modulus)
|
||||
{
|
||||
raw_add(r, a);
|
||||
raw_try_sub(r, modulus);
|
||||
}
|
||||
|
||||
|
||||
void fprime_sub(byte *r, const byte *a, const byte *modulus)
|
||||
{
|
||||
raw_add(r, modulus);
|
||||
raw_try_sub(r, a);
|
||||
raw_try_sub(r, modulus);
|
||||
}
|
||||
|
||||
|
||||
void fprime_mul(byte *r, const byte *a, const byte *b,
|
||||
const byte *modulus)
|
||||
{
|
||||
word16 c = 0;
|
||||
int i,j;
|
||||
|
||||
XMEMSET(r, 0, F25519_SIZE);
|
||||
|
||||
for (i = prime_msb(modulus); i >= 0; i--) {
|
||||
const byte bit = (b[i >> 3] >> (i & 7)) & 1;
|
||||
byte plusa[F25519_SIZE];
|
||||
|
||||
for (j = 0; j < F25519_SIZE; j++) {
|
||||
c |= ((word16)r[j]) << 1;
|
||||
r[j] = (byte)c;
|
||||
c >>= 8;
|
||||
}
|
||||
raw_try_sub(r, modulus);
|
||||
|
||||
fprime_copy(plusa, r);
|
||||
fprime_add(plusa, a, modulus);
|
||||
|
||||
fprime_select(r, r, plusa, bit);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void fe_load(byte *x, word32 c)
|
||||
{
|
||||
word32 i;
|
||||
|
||||
for (i = 0; i < sizeof(c); i++) {
|
||||
x[i] = c;
|
||||
c >>= 8;
|
||||
}
|
||||
|
||||
for (; i < F25519_SIZE; i++)
|
||||
x[i] = 0;
|
||||
}
|
||||
|
||||
|
||||
void fe_normalize(byte *x)
|
||||
{
|
||||
byte minusp[F25519_SIZE];
|
||||
word16 c;
|
||||
int i;
|
||||
|
||||
/* Reduce using 2^255 = 19 mod p */
|
||||
c = (x[31] >> 7) * 19;
|
||||
x[31] &= 127;
|
||||
|
||||
for (i = 0; i < F25519_SIZE; i++) {
|
||||
c += x[i];
|
||||
x[i] = (byte)c;
|
||||
c >>= 8;
|
||||
}
|
||||
|
||||
/* The number is now less than 2^255 + 18, and therefore less than
|
||||
* 2p. Try subtracting p, and conditionally load the subtracted
|
||||
* value if underflow did not occur.
|
||||
*/
|
||||
c = 19;
|
||||
|
||||
for (i = 0; i + 1 < F25519_SIZE; i++) {
|
||||
c += x[i];
|
||||
minusp[i] = (byte)c;
|
||||
c >>= 8;
|
||||
}
|
||||
|
||||
c += ((word16)x[i]) - 128;
|
||||
minusp[31] = (byte)c;
|
||||
|
||||
/* Load x-p if no underflow */
|
||||
fe_select(x, minusp, x, (c >> 15) & 1);
|
||||
}
|
||||
|
||||
|
||||
void fe_select(byte *dst,
|
||||
const byte *zero, const byte *one,
|
||||
byte condition)
|
||||
{
|
||||
const byte mask = -condition;
|
||||
int i;
|
||||
|
||||
for (i = 0; i < F25519_SIZE; i++)
|
||||
dst[i] = zero[i] ^ (mask & (one[i] ^ zero[i]));
|
||||
}
|
||||
|
||||
|
||||
void lm_add(byte* r, const byte* a, const byte* b)
|
||||
{
|
||||
word16 c = 0;
|
||||
int i;
|
||||
|
||||
/* Add */
|
||||
for (i = 0; i < F25519_SIZE; i++) {
|
||||
c >>= 8;
|
||||
c += ((word16)a[i]) + ((word16)b[i]);
|
||||
r[i] = (byte)c;
|
||||
}
|
||||
|
||||
/* Reduce with 2^255 = 19 mod p */
|
||||
r[31] &= 127;
|
||||
c = (c >> 7) * 19;
|
||||
|
||||
for (i = 0; i < F25519_SIZE; i++) {
|
||||
c += r[i];
|
||||
r[i] = (byte)c;
|
||||
c >>= 8;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void lm_sub(byte* r, const byte* a, const byte* b)
|
||||
{
|
||||
word32 c = 0;
|
||||
int i;
|
||||
|
||||
/* Calculate a + 2p - b, to avoid underflow */
|
||||
c = 218;
|
||||
for (i = 0; i + 1 < F25519_SIZE; i++) {
|
||||
c += 65280 + ((word32)a[i]) - ((word32)b[i]);
|
||||
r[i] = c;
|
||||
c >>= 8;
|
||||
}
|
||||
|
||||
c += ((word32)a[31]) - ((word32)b[31]);
|
||||
r[31] = c & 127;
|
||||
c = (c >> 7) * 19;
|
||||
|
||||
for (i = 0; i < F25519_SIZE; i++) {
|
||||
c += r[i];
|
||||
r[i] = c;
|
||||
c >>= 8;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void lm_neg(byte* r, const byte* a)
|
||||
{
|
||||
word32 c = 0;
|
||||
int i;
|
||||
|
||||
/* Calculate 2p - a, to avoid underflow */
|
||||
c = 218;
|
||||
for (i = 0; i + 1 < F25519_SIZE; i++) {
|
||||
c += 65280 - ((word32)a[i]);
|
||||
r[i] = c;
|
||||
c >>= 8;
|
||||
}
|
||||
|
||||
c -= ((word32)a[31]);
|
||||
r[31] = c & 127;
|
||||
c = (c >> 7) * 19;
|
||||
|
||||
for (i = 0; i < F25519_SIZE; i++) {
|
||||
c += r[i];
|
||||
r[i] = c;
|
||||
c >>= 8;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void fe_mul__distinct(byte *r, const byte *a, const byte *b)
|
||||
{
|
||||
word32 c = 0;
|
||||
int i;
|
||||
|
||||
for (i = 0; i < F25519_SIZE; i++) {
|
||||
int j;
|
||||
|
||||
c >>= 8;
|
||||
for (j = 0; j <= i; j++)
|
||||
c += ((word32)a[j]) * ((word32)b[i - j]);
|
||||
|
||||
for (; j < F25519_SIZE; j++)
|
||||
c += ((word32)a[j]) *
|
||||
((word32)b[i + F25519_SIZE - j]) * 38;
|
||||
|
||||
r[i] = c;
|
||||
}
|
||||
|
||||
r[31] &= 127;
|
||||
c = (c >> 7) * 19;
|
||||
|
||||
for (i = 0; i < F25519_SIZE; i++) {
|
||||
c += r[i];
|
||||
r[i] = c;
|
||||
c >>= 8;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void lm_mul(byte *r, const byte* a, const byte *b)
|
||||
{
|
||||
byte tmp[F25519_SIZE];
|
||||
|
||||
fe_mul__distinct(tmp, a, b);
|
||||
lm_copy(r, tmp);
|
||||
}
|
||||
|
||||
|
||||
void fe_mul_c(byte *r, const byte *a, word32 b)
|
||||
{
|
||||
word32 c = 0;
|
||||
int i;
|
||||
|
||||
for (i = 0; i < F25519_SIZE; i++) {
|
||||
c >>= 8;
|
||||
c += b * ((word32)a[i]);
|
||||
r[i] = c;
|
||||
}
|
||||
|
||||
r[31] &= 127;
|
||||
c >>= 7;
|
||||
c *= 19;
|
||||
|
||||
for (i = 0; i < F25519_SIZE; i++) {
|
||||
c += r[i];
|
||||
r[i] = c;
|
||||
c >>= 8;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void fe_inv__distinct(byte *r, const byte *x)
|
||||
{
|
||||
byte s[F25519_SIZE];
|
||||
int i;
|
||||
|
||||
/* This is a prime field, so by Fermat's little theorem:
|
||||
*
|
||||
* x^(p-1) = 1 mod p
|
||||
*
|
||||
* Therefore, raise to (p-2) = 2^255-21 to get a multiplicative
|
||||
* inverse.
|
||||
*
|
||||
* This is a 255-bit binary number with the digits:
|
||||
*
|
||||
* 11111111... 01011
|
||||
*
|
||||
* We compute the result by the usual binary chain, but
|
||||
* alternate between keeping the accumulator in r and s, so as
|
||||
* to avoid copying temporaries.
|
||||
*/
|
||||
|
||||
/* 1 1 */
|
||||
fe_mul__distinct(s, x, x);
|
||||
fe_mul__distinct(r, s, x);
|
||||
|
||||
/* 1 x 248 */
|
||||
for (i = 0; i < 248; i++) {
|
||||
fe_mul__distinct(s, r, r);
|
||||
fe_mul__distinct(r, s, x);
|
||||
}
|
||||
|
||||
/* 0 */
|
||||
fe_mul__distinct(s, r, r);
|
||||
|
||||
/* 1 */
|
||||
fe_mul__distinct(r, s, s);
|
||||
fe_mul__distinct(s, r, x);
|
||||
|
||||
/* 0 */
|
||||
fe_mul__distinct(r, s, s);
|
||||
|
||||
/* 1 */
|
||||
fe_mul__distinct(s, r, r);
|
||||
fe_mul__distinct(r, s, x);
|
||||
|
||||
/* 1 */
|
||||
fe_mul__distinct(s, r, r);
|
||||
fe_mul__distinct(r, s, x);
|
||||
}
|
||||
|
||||
|
||||
void lm_invert(byte *r, const byte *x)
|
||||
{
|
||||
byte tmp[F25519_SIZE];
|
||||
|
||||
fe_inv__distinct(tmp, x);
|
||||
lm_copy(r, tmp);
|
||||
}
|
||||
|
||||
|
||||
/* Raise x to the power of (p-5)/8 = 2^252-3, using s for temporary
|
||||
* storage.
|
||||
*/
|
||||
static void exp2523(byte *r, const byte *x, byte *s)
|
||||
{
|
||||
int i;
|
||||
|
||||
/* This number is a 252-bit number with the binary expansion:
|
||||
*
|
||||
* 111111... 01
|
||||
*/
|
||||
|
||||
/* 1 1 */
|
||||
fe_mul__distinct(r, x, x);
|
||||
fe_mul__distinct(s, r, x);
|
||||
|
||||
/* 1 x 248 */
|
||||
for (i = 0; i < 248; i++) {
|
||||
fe_mul__distinct(r, s, s);
|
||||
fe_mul__distinct(s, r, x);
|
||||
}
|
||||
|
||||
/* 0 */
|
||||
fe_mul__distinct(r, s, s);
|
||||
|
||||
/* 1 */
|
||||
fe_mul__distinct(s, r, r);
|
||||
fe_mul__distinct(r, s, x);
|
||||
}
|
||||
|
||||
|
||||
void fe_sqrt(byte *r, const byte *a)
|
||||
{
|
||||
byte v[F25519_SIZE];
|
||||
byte i[F25519_SIZE];
|
||||
byte x[F25519_SIZE];
|
||||
byte y[F25519_SIZE];
|
||||
|
||||
/* v = (2a)^((p-5)/8) [x = 2a] */
|
||||
fe_mul_c(x, a, 2);
|
||||
exp2523(v, x, y);
|
||||
|
||||
/* i = 2av^2 - 1 */
|
||||
fe_mul__distinct(y, v, v);
|
||||
fe_mul__distinct(i, x, y);
|
||||
fe_load(y, 1);
|
||||
lm_sub(i, i, y);
|
||||
|
||||
/* r = avi */
|
||||
fe_mul__distinct(x, v, a);
|
||||
fe_mul__distinct(r, x, i);
|
||||
}
|
||||
|
||||
#endif /* CURVE25519_SMALL || ED25519_SMALL */
|
||||
#endif /* HAVE_CURVE25519 || HAVE_ED25519 */
|
File diff suppressed because it is too large
Load Diff
@ -1,625 +0,0 @@
|
||||
/* fe_x25519_128.i
|
||||
*
|
||||
* Copyright (C) 2006-2020 wolfSSL Inc.
|
||||
*
|
||||
* This file is part of wolfSSL.
|
||||
*
|
||||
* wolfSSL is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* wolfSSL is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA
|
||||
*/
|
||||
|
||||
void fe_init(void)
|
||||
{
|
||||
}
|
||||
|
||||
/* Convert a number represented as an array of bytes to an array of words with
|
||||
* 51-bits of data in each word.
|
||||
*
|
||||
* in An array of bytes.
|
||||
* out An array of words.
|
||||
*/
|
||||
void fe_frombytes(fe out, const unsigned char *in)
|
||||
{
|
||||
out[0] = (((int64_t)((in[ 0] ) )) )
|
||||
| (((int64_t)((in[ 1] ) )) << 8)
|
||||
| (((int64_t)((in[ 2] ) )) << 16)
|
||||
| (((int64_t)((in[ 3] ) )) << 24)
|
||||
| (((int64_t)((in[ 4] ) )) << 32)
|
||||
| (((int64_t)((in[ 5] ) )) << 40)
|
||||
| (((int64_t)((in[ 6] ) & 0x07)) << 48);
|
||||
out[1] = (((int64_t)((in[ 6] >> 3) & 0x1f)) )
|
||||
| (((int64_t)((in[ 7] ) )) << 5)
|
||||
| (((int64_t)((in[ 8] ) )) << 13)
|
||||
| (((int64_t)((in[ 9] ) )) << 21)
|
||||
| (((int64_t)((in[10] ) )) << 29)
|
||||
| (((int64_t)((in[11] ) )) << 37)
|
||||
| (((int64_t)((in[12] ) & 0x3f)) << 45);
|
||||
out[2] = (((int64_t)((in[12] >> 6) & 0x03)) )
|
||||
| (((int64_t)((in[13] ) )) << 2)
|
||||
| (((int64_t)((in[14] ) )) << 10)
|
||||
| (((int64_t)((in[15] ) )) << 18)
|
||||
| (((int64_t)((in[16] ) )) << 26)
|
||||
| (((int64_t)((in[17] ) )) << 34)
|
||||
| (((int64_t)((in[18] ) )) << 42)
|
||||
| (((int64_t)((in[19] ) & 0x01)) << 50);
|
||||
out[3] = (((int64_t)((in[19] >> 1) & 0x7f)) )
|
||||
| (((int64_t)((in[20] ) )) << 7)
|
||||
| (((int64_t)((in[21] ) )) << 15)
|
||||
| (((int64_t)((in[22] ) )) << 23)
|
||||
| (((int64_t)((in[23] ) )) << 31)
|
||||
| (((int64_t)((in[24] ) )) << 39)
|
||||
| (((int64_t)((in[25] ) & 0x0f)) << 47);
|
||||
out[4] = (((int64_t)((in[25] >> 4) & 0x0f)) )
|
||||
| (((int64_t)((in[26] ) )) << 4)
|
||||
| (((int64_t)((in[27] ) )) << 12)
|
||||
| (((int64_t)((in[28] ) )) << 20)
|
||||
| (((int64_t)((in[29] ) )) << 28)
|
||||
| (((int64_t)((in[30] ) )) << 36)
|
||||
| (((int64_t)((in[31] ) & 0x7f)) << 44);
|
||||
}
|
||||
|
||||
/* Convert a number represented as an array of words to an array of bytes.
|
||||
* The array of words is normalized to an array of 51-bit data words and if
|
||||
* greater than the mod, modulo reduced by the prime 2^255 - 1.
|
||||
*
|
||||
* n An array of words.
|
||||
* out An array of bytes.
|
||||
*/
|
||||
void fe_tobytes(unsigned char *out, const fe n)
|
||||
{
|
||||
fe in;
|
||||
int64_t c;
|
||||
|
||||
in[0] = n[0];
|
||||
in[1] = n[1];
|
||||
in[2] = n[2];
|
||||
in[3] = n[3];
|
||||
in[4] = n[4];
|
||||
|
||||
/* Normalize to 51-bits of data per word. */
|
||||
in[0] += (in[4] >> 51) * 19; in[4] &= 0x7ffffffffffff;
|
||||
|
||||
in[1] += in[0] >> 51; in[0] &= 0x7ffffffffffff;
|
||||
in[2] += in[1] >> 51; in[1] &= 0x7ffffffffffff;
|
||||
in[3] += in[2] >> 51; in[2] &= 0x7ffffffffffff;
|
||||
in[4] += in[3] >> 51; in[3] &= 0x7ffffffffffff;
|
||||
in[0] += (in[4] >> 51) * 19;
|
||||
in[4] &= 0x7ffffffffffff;
|
||||
|
||||
c = (in[0] + 19) >> 51;
|
||||
c = (in[1] + c) >> 51;
|
||||
c = (in[2] + c) >> 51;
|
||||
c = (in[3] + c) >> 51;
|
||||
c = (in[4] + c) >> 51;
|
||||
in[0] += c * 19;
|
||||
in[1] += in[0] >> 51; in[0] &= 0x7ffffffffffff;
|
||||
in[2] += in[1] >> 51; in[1] &= 0x7ffffffffffff;
|
||||
in[3] += in[2] >> 51; in[2] &= 0x7ffffffffffff;
|
||||
in[4] += in[3] >> 51; in[3] &= 0x7ffffffffffff;
|
||||
in[4] &= 0x7ffffffffffff;
|
||||
|
||||
out[ 0] = (((byte)((in[0] ) )) );
|
||||
out[ 1] = (((byte)((in[0] >> 8) )) );
|
||||
out[ 2] = (((byte)((in[0] >> 16) )) );
|
||||
out[ 3] = (((byte)((in[0] >> 24) )) );
|
||||
out[ 4] = (((byte)((in[0] >> 32) )) );
|
||||
out[ 5] = (((byte)((in[0] >> 40) )) );
|
||||
out[ 6] = (((byte)((in[0] >> 48) & 0x07)) )
|
||||
| (((byte)((in[1] ) & 0x1f)) << 3);
|
||||
out[ 7] = (((byte)((in[1] >> 5) )) );
|
||||
out[ 8] = (((byte)((in[1] >> 13) )) );
|
||||
out[ 9] = (((byte)((in[1] >> 21) )) );
|
||||
out[10] = (((byte)((in[1] >> 29) )) );
|
||||
out[11] = (((byte)((in[1] >> 37) )) );
|
||||
out[12] = (((byte)((in[1] >> 45) & 0x3f)) )
|
||||
| (((byte)((in[2] ) & 0x03)) << 6);
|
||||
out[13] = (((byte)((in[2] >> 2) )) );
|
||||
out[14] = (((byte)((in[2] >> 10) )) );
|
||||
out[15] = (((byte)((in[2] >> 18) )) );
|
||||
out[16] = (((byte)((in[2] >> 26) )) );
|
||||
out[17] = (((byte)((in[2] >> 34) )) );
|
||||
out[18] = (((byte)((in[2] >> 42) )) );
|
||||
out[19] = (((byte)((in[2] >> 50) & 0x01)) )
|
||||
| (((byte)((in[3] ) & 0x7f)) << 1);
|
||||
out[20] = (((byte)((in[3] >> 7) )) );
|
||||
out[21] = (((byte)((in[3] >> 15) )) );
|
||||
out[22] = (((byte)((in[3] >> 23) )) );
|
||||
out[23] = (((byte)((in[3] >> 31) )) );
|
||||
out[24] = (((byte)((in[3] >> 39) )) );
|
||||
out[25] = (((byte)((in[3] >> 47) & 0x0f)) )
|
||||
| (((byte)((in[4] ) & 0x0f)) << 4);
|
||||
out[26] = (((byte)((in[4] >> 4) )) );
|
||||
out[27] = (((byte)((in[4] >> 12) )) );
|
||||
out[28] = (((byte)((in[4] >> 20) )) );
|
||||
out[29] = (((byte)((in[4] >> 28) )) );
|
||||
out[30] = (((byte)((in[4] >> 36) )) );
|
||||
out[31] = (((byte)((in[4] >> 44) & 0x7f)) );
|
||||
}
|
||||
|
||||
/* Set the field element to 1.
|
||||
*
|
||||
* n The field element number.
|
||||
*/
|
||||
void fe_1(fe n)
|
||||
{
|
||||
n[0] = 0x0000000000001;
|
||||
n[1] = 0x0000000000000;
|
||||
n[2] = 0x0000000000000;
|
||||
n[3] = 0x0000000000000;
|
||||
n[4] = 0x0000000000000;
|
||||
}
|
||||
|
||||
/* Set the field element to 0.
|
||||
*
|
||||
* n The field element number.
|
||||
*/
|
||||
void fe_0(fe n)
|
||||
{
|
||||
n[0] = 0x0000000000000;
|
||||
n[1] = 0x0000000000000;
|
||||
n[2] = 0x0000000000000;
|
||||
n[3] = 0x0000000000000;
|
||||
n[4] = 0x0000000000000;
|
||||
}
|
||||
|
||||
/* Copy field element a into field element r.
|
||||
*
|
||||
* r Field element to copy into.
|
||||
* a Field element to copy.
|
||||
*/
|
||||
void fe_copy(fe r, const fe a)
|
||||
{
|
||||
r[0] = a[0];
|
||||
r[1] = a[1];
|
||||
r[2] = a[2];
|
||||
r[3] = a[3];
|
||||
r[4] = a[4];
|
||||
}
|
||||
|
||||
/* Constant time, conditional swap of field elements a and b.
|
||||
*
|
||||
* a A field element.
|
||||
* b A field element.
|
||||
* c If 1 then swap and if 0 then don't swap.
|
||||
*/
|
||||
void fe_cswap(fe a, fe b, int c)
|
||||
{
|
||||
int64_t m = c;
|
||||
int64_t t0, t1, t2, t3, t4;
|
||||
|
||||
/* Convert conditional into mask. */
|
||||
m = -m;
|
||||
t0 = m & (a[0] ^ b[0]);
|
||||
t1 = m & (a[1] ^ b[1]);
|
||||
t2 = m & (a[2] ^ b[2]);
|
||||
t3 = m & (a[3] ^ b[3]);
|
||||
t4 = m & (a[4] ^ b[4]);
|
||||
|
||||
a[0] ^= t0;
|
||||
a[1] ^= t1;
|
||||
a[2] ^= t2;
|
||||
a[3] ^= t3;
|
||||
a[4] ^= t4;
|
||||
|
||||
b[0] ^= t0;
|
||||
b[1] ^= t1;
|
||||
b[2] ^= t2;
|
||||
b[3] ^= t3;
|
||||
b[4] ^= t4;
|
||||
}
|
||||
|
||||
/* Subtract b from a into r. (r = a - b)
|
||||
*
|
||||
* r A field element.
|
||||
* a A field element.
|
||||
* b A field element.
|
||||
*/
|
||||
void fe_sub(fe r, const fe a, const fe b)
|
||||
{
|
||||
r[0] = a[0] - b[0];
|
||||
r[1] = a[1] - b[1];
|
||||
r[2] = a[2] - b[2];
|
||||
r[3] = a[3] - b[3];
|
||||
r[4] = a[4] - b[4];
|
||||
}
|
||||
|
||||
/* Add b to a into r. (r = a + b)
|
||||
*
|
||||
* r A field element.
|
||||
* a A field element.
|
||||
* b A field element.
|
||||
*/
|
||||
void fe_add(fe r, const fe a, const fe b)
|
||||
{
|
||||
r[0] = a[0] + b[0];
|
||||
r[1] = a[1] + b[1];
|
||||
r[2] = a[2] + b[2];
|
||||
r[3] = a[3] + b[3];
|
||||
r[4] = a[4] + b[4];
|
||||
}
|
||||
|
||||
/* Multiply a and b into r. (r = a * b)
|
||||
*
|
||||
* r A field element.
|
||||
* a A field element.
|
||||
* b A field element.
|
||||
*/
|
||||
void fe_mul(fe r, const fe a, const fe b)
|
||||
{
|
||||
const __int128_t k19 = 19;
|
||||
__int128_t t0 = ((__int128_t)a[0]) * b[0];
|
||||
__int128_t t1 = ((__int128_t)a[0]) * b[1]
|
||||
+ ((__int128_t)a[1]) * b[0];
|
||||
__int128_t t2 = ((__int128_t)a[0]) * b[2]
|
||||
+ ((__int128_t)a[1]) * b[1]
|
||||
+ ((__int128_t)a[2]) * b[0];
|
||||
__int128_t t3 = ((__int128_t)a[0]) * b[3]
|
||||
+ ((__int128_t)a[1]) * b[2]
|
||||
+ ((__int128_t)a[2]) * b[1]
|
||||
+ ((__int128_t)a[3]) * b[0];
|
||||
__int128_t t4 = ((__int128_t)a[0]) * b[4]
|
||||
+ ((__int128_t)a[1]) * b[3]
|
||||
+ ((__int128_t)a[2]) * b[2]
|
||||
+ ((__int128_t)a[3]) * b[1]
|
||||
+ ((__int128_t)a[4]) * b[0];
|
||||
__int128_t t5 = ((__int128_t)a[1]) * b[4]
|
||||
+ ((__int128_t)a[2]) * b[3]
|
||||
+ ((__int128_t)a[3]) * b[2]
|
||||
+ ((__int128_t)a[4]) * b[1];
|
||||
__int128_t t6 = ((__int128_t)a[2]) * b[4]
|
||||
+ ((__int128_t)a[3]) * b[3]
|
||||
+ ((__int128_t)a[4]) * b[2];
|
||||
__int128_t t7 = ((__int128_t)a[3]) * b[4]
|
||||
+ ((__int128_t)a[4]) * b[3];
|
||||
__int128_t t8 = ((__int128_t)a[4]) * b[4];
|
||||
|
||||
/* Modulo reduce double long word. */
|
||||
t0 += t5 * k19;
|
||||
t1 += t6 * k19;
|
||||
t2 += t7 * k19;
|
||||
t3 += t8 * k19;
|
||||
|
||||
/* Normalize to 51-bits of data per word. */
|
||||
t0 += (t4 >> 51) * k19; t4 &= 0x7ffffffffffff;
|
||||
|
||||
t1 += t0 >> 51; r[0] = t0 & 0x7ffffffffffff;
|
||||
t2 += t1 >> 51; r[1] = t1 & 0x7ffffffffffff;
|
||||
t3 += t2 >> 51; r[2] = t2 & 0x7ffffffffffff;
|
||||
t4 += t3 >> 51; r[3] = t3 & 0x7ffffffffffff;
|
||||
r[0] += (t4 >> 51) * k19;
|
||||
r[4] = t4 & 0x7ffffffffffff;
|
||||
}
|
||||
|
||||
/* Square a and put result in r. (r = a * a)
|
||||
*
|
||||
* r A field element.
|
||||
* a A field element.
|
||||
* b A field element.
|
||||
*/
|
||||
void fe_sq(fe r, const fe a)
|
||||
{
|
||||
const __int128_t k19 = 19;
|
||||
const __int128_t k2 = 2;
|
||||
__int128_t t0 = ((__int128_t)a[0]) * a[0];
|
||||
__int128_t t1 = ((__int128_t)a[0]) * a[1] * k2;
|
||||
__int128_t t2 = ((__int128_t)a[0]) * a[2] * k2
|
||||
+ ((__int128_t)a[1]) * a[1];
|
||||
__int128_t t3 = ((__int128_t)a[0]) * a[3] * k2
|
||||
+ ((__int128_t)a[1]) * a[2] * k2;
|
||||
__int128_t t4 = ((__int128_t)a[0]) * a[4] * k2
|
||||
+ ((__int128_t)a[1]) * a[3] * k2
|
||||
+ ((__int128_t)a[2]) * a[2];
|
||||
__int128_t t5 = ((__int128_t)a[1]) * a[4] * k2
|
||||
+ ((__int128_t)a[2]) * a[3] * k2;
|
||||
__int128_t t6 = ((__int128_t)a[2]) * a[4] * k2
|
||||
+ ((__int128_t)a[3]) * a[3];
|
||||
__int128_t t7 = ((__int128_t)a[3]) * a[4] * k2;
|
||||
__int128_t t8 = ((__int128_t)a[4]) * a[4];
|
||||
|
||||
/* Modulo reduce double long word. */
|
||||
t0 += t5 * k19;
|
||||
t1 += t6 * k19;
|
||||
t2 += t7 * k19;
|
||||
t3 += t8 * k19;
|
||||
|
||||
/* Normalize to 51-bits of data per word. */
|
||||
t0 += (t4 >> 51) * k19; t4 &= 0x7ffffffffffff;
|
||||
|
||||
t1 += t0 >> 51; r[0] = t0 & 0x7ffffffffffff;
|
||||
t2 += t1 >> 51; r[1] = t1 & 0x7ffffffffffff;
|
||||
t3 += t2 >> 51; r[2] = t2 & 0x7ffffffffffff;
|
||||
t4 += t3 >> 51; r[3] = t3 & 0x7ffffffffffff;
|
||||
r[0] += (t4 >> 51) * k19;
|
||||
r[4] = t4 & 0x7ffffffffffff;
|
||||
}
|
||||
|
||||
/* Multiply a by 121666 and put result in r. (r = 121666 * a)
|
||||
*
|
||||
* r A field element.
|
||||
* a A field element.
|
||||
* b A field element.
|
||||
*/
|
||||
void fe_mul121666(fe r, fe a)
|
||||
{
|
||||
const __int128_t k19 = 19;
|
||||
const __int128_t k121666 = 121666;
|
||||
__int128_t t0 = ((__int128_t)a[0]) * k121666;
|
||||
__int128_t t1 = ((__int128_t)a[1]) * k121666;
|
||||
__int128_t t2 = ((__int128_t)a[2]) * k121666;
|
||||
__int128_t t3 = ((__int128_t)a[3]) * k121666;
|
||||
__int128_t t4 = ((__int128_t)a[4]) * k121666;
|
||||
|
||||
/* Normalize to 51-bits of data per word. */
|
||||
t0 += (t4 >> 51) * k19; t4 &= 0x7ffffffffffff;
|
||||
|
||||
t1 += t0 >> 51; r[0] = t0 & 0x7ffffffffffff;
|
||||
t2 += t1 >> 51; r[1] = t1 & 0x7ffffffffffff;
|
||||
t3 += t2 >> 51; r[2] = t2 & 0x7ffffffffffff;
|
||||
t4 += t3 >> 51; r[3] = t3 & 0x7ffffffffffff;
|
||||
r[0] += (t4 >> 51) * k19;
|
||||
r[4] = t4 & 0x7ffffffffffff;
|
||||
}
|
||||
|
||||
/* Find the inverse of a modulo 2^255 - 1 and put result in r.
|
||||
* (r * a) mod (2^255 - 1) = 1
|
||||
* Implementation is constant time.
|
||||
*
|
||||
* r A field element.
|
||||
* a A field element.
|
||||
*/
|
||||
void fe_invert(fe r, const fe a)
|
||||
{
|
||||
fe t0, t1, t2, t3;
|
||||
int i;
|
||||
|
||||
/* a ^ (2^255 - 21) */
|
||||
fe_sq(t0, a); for (i = 1; i < 1; ++i) fe_sq(t0, t0);
|
||||
fe_sq(t1, t0); for (i = 1; i < 2; ++i) fe_sq(t1, t1); fe_mul(t1, a, t1);
|
||||
fe_mul(t0, t0, t1);
|
||||
fe_sq(t2, t0); for (i = 1; i < 1; ++i) fe_sq(t2, t2); fe_mul(t1, t1, t2);
|
||||
fe_sq(t2, t1); for (i = 1; i < 5; ++i) fe_sq(t2, t2); fe_mul(t1, t2, t1);
|
||||
fe_sq(t2, t1); for (i = 1; i < 10; ++i) fe_sq(t2, t2); fe_mul(t2, t2, t1);
|
||||
fe_sq(t3, t2); for (i = 1; i < 20; ++i) fe_sq(t3, t3); fe_mul(t2, t3, t2);
|
||||
fe_sq(t2, t2); for (i = 1; i < 10; ++i) fe_sq(t2, t2); fe_mul(t1, t2, t1);
|
||||
fe_sq(t2, t1); for (i = 1; i < 50; ++i) fe_sq(t2, t2); fe_mul(t2, t2, t1);
|
||||
fe_sq(t3, t2); for (i = 1; i < 100; ++i) fe_sq(t3, t3); fe_mul(t2, t3, t2);
|
||||
fe_sq(t2, t2); for (i = 1; i < 50; ++i) fe_sq(t2, t2); fe_mul(t1, t2, t1);
|
||||
fe_sq(t1, t1); for (i = 1; i < 5; ++i) fe_sq(t1, t1); fe_mul( r, t1, t0);
|
||||
}
|
||||
|
||||
#ifndef CURVE25519_SMALL
|
||||
/* Scalar multiply the field element a by n using Montgomery Ladder and places
|
||||
* result in r.
|
||||
*
|
||||
* r A field element as an array of bytes.
|
||||
* n The scalar as an array of bytes.
|
||||
* a A field element as an array of bytes.
|
||||
*/
|
||||
int curve25519(byte* r, const byte* n, const byte* a)
|
||||
{
|
||||
fe x1, x2, z2, x3, z3;
|
||||
fe t0, t1;
|
||||
int pos;
|
||||
unsigned int swap;
|
||||
unsigned int b;
|
||||
|
||||
fe_frombytes(x1, a);
|
||||
fe_1(x2);
|
||||
fe_0(z2);
|
||||
fe_copy(x3, x1);
|
||||
fe_1(z3);
|
||||
|
||||
swap = 0;
|
||||
for (pos = 254;pos >= 0;--pos) {
|
||||
b = n[pos / 8] >> (pos & 7);
|
||||
b &= 1;
|
||||
swap ^= b;
|
||||
fe_cswap(x2, x3, swap);
|
||||
fe_cswap(z2, z3, swap);
|
||||
swap = b;
|
||||
|
||||
fe_sub(t0, x3, z3);
|
||||
fe_sub(t1, x2, z2);
|
||||
fe_add(x2, x2, z2);
|
||||
fe_add(z2, x3, z3);
|
||||
fe_mul(z3, t0, x2);
|
||||
fe_mul(z2, z2, t1);
|
||||
fe_sq(t0, t1);
|
||||
fe_sq(t1, x2);
|
||||
fe_add(x3, z3, z2);
|
||||
fe_sub(z2, z3, z2);
|
||||
fe_mul(x2, t1, t0);
|
||||
fe_sub(t1, t1, t0);
|
||||
fe_sq(z2, z2);
|
||||
fe_mul121666(z3, t1);
|
||||
fe_sq(x3, x3);
|
||||
fe_add(t0, t0, z3);
|
||||
fe_mul(z3, x1, z2);
|
||||
fe_mul(z2, t1, t0);
|
||||
}
|
||||
fe_cswap(x2, x3, swap);
|
||||
fe_cswap(z2, z3, swap);
|
||||
|
||||
fe_invert(z2, z2);
|
||||
fe_mul(x2, x2, z2);
|
||||
fe_tobytes(r, x2);
|
||||
|
||||
return 0;
|
||||
}
|
||||
#endif /* !CURVE25519_SMALL */
|
||||
|
||||
/* The field element value 0 as an array of bytes. */
|
||||
static const unsigned char zero[32] = {0};
|
||||
|
||||
/* Constant time check as to whether a is not 0.
|
||||
*
|
||||
* a A field element.
|
||||
*/
|
||||
int fe_isnonzero(const fe a)
|
||||
{
|
||||
unsigned char s[32];
|
||||
fe_tobytes(s, a);
|
||||
return ConstantCompare(s, zero, 32);
|
||||
}
|
||||
|
||||
/* Checks whether a is negative.
|
||||
*
|
||||
* a A field element.
|
||||
*/
|
||||
int fe_isnegative(const fe a)
|
||||
{
|
||||
unsigned char s[32];
|
||||
fe_tobytes(s, a);
|
||||
return s[0] & 1;
|
||||
}
|
||||
|
||||
/* Negates field element a and stores the result in r.
|
||||
*
|
||||
* r A field element.
|
||||
* a A field element.
|
||||
*/
|
||||
void fe_neg(fe r, const fe a)
|
||||
{
|
||||
r[0] = -a[0];
|
||||
r[1] = -a[1];
|
||||
r[2] = -a[2];
|
||||
r[3] = -a[3];
|
||||
r[4] = -a[4];
|
||||
}
|
||||
|
||||
/* Constant time, conditional move of b into a.
|
||||
* a is not changed if the condition is 0.
|
||||
*
|
||||
* a A field element.
|
||||
* b A field element.
|
||||
* c If 1 then copy and if 0 then don't copy.
|
||||
*/
|
||||
void fe_cmov(fe a, const fe b, int c)
|
||||
{
|
||||
int64_t m = c;
|
||||
int64_t t0, t1, t2, t3, t4;
|
||||
|
||||
/* Convert conditional into mask. */
|
||||
m = -m;
|
||||
t0 = m & (a[0] ^ b[0]);
|
||||
t1 = m & (a[1] ^ b[1]);
|
||||
t2 = m & (a[2] ^ b[2]);
|
||||
t3 = m & (a[3] ^ b[3]);
|
||||
t4 = m & (a[4] ^ b[4]);
|
||||
|
||||
a[0] ^= t0;
|
||||
a[1] ^= t1;
|
||||
a[2] ^= t2;
|
||||
a[3] ^= t3;
|
||||
a[4] ^= t4;
|
||||
}
|
||||
|
||||
void fe_pow22523(fe r, const fe a)
|
||||
{
|
||||
fe t0, t1, t2;
|
||||
int i;
|
||||
|
||||
/* a ^ (2^255 - 23) */
|
||||
fe_sq(t0, a); for (i = 1; i < 1; ++i) fe_sq(t0, t0);
|
||||
fe_sq(t1, t0); for (i = 1; i < 2; ++i) fe_sq(t1, t1); fe_mul(t1, a, t1);
|
||||
fe_mul(t0, t0, t1);
|
||||
fe_sq(t0, t0); for (i = 1; i < 1; ++i) fe_sq(t0, t0); fe_mul(t0, t1, t0);
|
||||
fe_sq(t1, t0); for (i = 1; i < 5; ++i) fe_sq(t1, t1); fe_mul(t0, t1, t0);
|
||||
fe_sq(t1, t0); for (i = 1; i < 10; ++i) fe_sq(t1, t1); fe_mul(t1, t1, t0);
|
||||
fe_sq(t2, t1); for (i = 1; i < 20; ++i) fe_sq(t2, t2); fe_mul(t1, t2, t1);
|
||||
fe_sq(t1, t1); for (i = 1; i < 10; ++i) fe_sq(t1, t1); fe_mul(t0, t1, t0);
|
||||
fe_sq(t1, t0); for (i = 1; i < 50; ++i) fe_sq(t1, t1); fe_mul(t1, t1, t0);
|
||||
fe_sq(t2, t1); for (i = 1; i < 100; ++i) fe_sq(t2, t2); fe_mul(t1, t2, t1);
|
||||
fe_sq(t1, t1); for (i = 1; i < 50; ++i) fe_sq(t1, t1); fe_mul(t0, t1, t0);
|
||||
fe_sq(t0, t0); for (i = 1; i < 2; ++i) fe_sq(t0, t0); fe_mul( r, t0, a);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
/* Double the square of a and put result in r. (r = 2 * a * a)
|
||||
*
|
||||
* r A field element.
|
||||
* a A field element.
|
||||
* b A field element.
|
||||
*/
|
||||
void fe_sq2(fe r, const fe a)
|
||||
{
|
||||
const __int128_t k2 = 2;
|
||||
const __int128_t k19 = 19;
|
||||
__int128_t t0 = k2 * (((__int128_t)a[0]) * a[0]);
|
||||
__int128_t t1 = k2 * (((__int128_t)a[0]) * a[1] * k2);
|
||||
__int128_t t2 = k2 * (((__int128_t)a[0]) * a[2] * k2
|
||||
+ ((__int128_t)a[1]) * a[1]);
|
||||
__int128_t t3 = k2 * (((__int128_t)a[0]) * a[3] * k2
|
||||
+ ((__int128_t)a[1]) * a[2] * k2);
|
||||
__int128_t t4 = k2 * (((__int128_t)a[0]) * a[4] * k2
|
||||
+ ((__int128_t)a[1]) * a[3] * k2
|
||||
+ ((__int128_t)a[2]) * a[2]);
|
||||
__int128_t t5 = k2 * (((__int128_t)a[1]) * a[4] * k2
|
||||
+ ((__int128_t)a[2]) * a[3] * k2);
|
||||
__int128_t t6 = k2 * (((__int128_t)a[2]) * a[4] * k2
|
||||
+ ((__int128_t)a[3]) * a[3]);
|
||||
__int128_t t7 = k2 * (((__int128_t)a[3]) * a[4] * k2);
|
||||
__int128_t t8 = k2 * (((__int128_t)a[4]) * a[4]);
|
||||
|
||||
/* Modulo reduce double long word. */
|
||||
t0 += t5 * k19;
|
||||
t1 += t6 * k19;
|
||||
t2 += t7 * k19;
|
||||
t3 += t8 * k19;
|
||||
|
||||
/* Normalize to 51-bits of data per word. */
|
||||
t0 += (t4 >> 51) * k19; t4 &= 0x7ffffffffffff;
|
||||
|
||||
t1 += t0 >> 51; r[0] = t0 & 0x7ffffffffffff;
|
||||
t2 += t1 >> 51; r[1] = t1 & 0x7ffffffffffff;
|
||||
t3 += t2 >> 51; r[2] = t2 & 0x7ffffffffffff;
|
||||
t4 += t3 >> 51; r[3] = t3 & 0x7ffffffffffff;
|
||||
r[0] += (t4 >> 51) * k19;
|
||||
r[4] = t4 & 0x7ffffffffffff;
|
||||
}
|
||||
|
||||
/* Load 3 little endian bytes into a 64-bit word.
|
||||
*
|
||||
* in An array of bytes.
|
||||
* returns a 64-bit word.
|
||||
*/
|
||||
uint64_t load_3(const unsigned char *in)
|
||||
{
|
||||
uint64_t result;
|
||||
|
||||
result = ((((uint64_t)in[0]) ) |
|
||||
(((uint64_t)in[1]) << 8) |
|
||||
(((uint64_t)in[2]) << 16));
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/* Load 4 little endian bytes into a 64-bit word.
|
||||
*
|
||||
* in An array of bytes.
|
||||
* returns a 64-bit word.
|
||||
*/
|
||||
uint64_t load_4(const unsigned char *in)
|
||||
{
|
||||
uint64_t result;
|
||||
|
||||
result = ((((uint64_t)in[0]) ) |
|
||||
(((uint64_t)in[1]) << 8) |
|
||||
(((uint64_t)in[2]) << 16) |
|
||||
(((uint64_t)in[3]) << 24));
|
||||
|
||||
return result;
|
||||
}
|
||||
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -1,147 +0,0 @@
|
||||
/* fp_mul_comba_12.i
|
||||
*
|
||||
* Copyright (C) 2006-2020 wolfSSL Inc.
|
||||
*
|
||||
* This file is part of wolfSSL.
|
||||
*
|
||||
* wolfSSL is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* wolfSSL is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA
|
||||
*/
|
||||
|
||||
|
||||
|
||||
#ifdef TFM_MUL12
|
||||
int fp_mul_comba12(fp_int *A, fp_int *B, fp_int *C)
|
||||
{
|
||||
fp_digit c0, c1, c2;
|
||||
#ifndef WOLFSSL_SMALL_STACK
|
||||
fp_digit at[24];
|
||||
#else
|
||||
fp_digit *at;
|
||||
#endif
|
||||
|
||||
#ifdef WOLFSSL_SMALL_STACK
|
||||
at = (fp_digit*)XMALLOC(sizeof(fp_digit) * 24, NULL, DYNAMIC_TYPE_TMP_BUFFER);
|
||||
if (at == NULL)
|
||||
return FP_MEM;
|
||||
#endif
|
||||
|
||||
XMEMCPY(at, A->dp, 12 * sizeof(fp_digit));
|
||||
XMEMCPY(at+12, B->dp, 12 * sizeof(fp_digit));
|
||||
COMBA_START;
|
||||
|
||||
COMBA_CLEAR;
|
||||
/* 0 */
|
||||
MULADD(at[0], at[12]);
|
||||
COMBA_STORE(C->dp[0]);
|
||||
/* 1 */
|
||||
COMBA_FORWARD;
|
||||
MULADD(at[0], at[13]); MULADD(at[1], at[12]);
|
||||
COMBA_STORE(C->dp[1]);
|
||||
/* 2 */
|
||||
COMBA_FORWARD;
|
||||
MULADD(at[0], at[14]); MULADD(at[1], at[13]); MULADD(at[2], at[12]);
|
||||
COMBA_STORE(C->dp[2]);
|
||||
/* 3 */
|
||||
COMBA_FORWARD;
|
||||
MULADD(at[0], at[15]); MULADD(at[1], at[14]); MULADD(at[2], at[13]); MULADD(at[3], at[12]);
|
||||
COMBA_STORE(C->dp[3]);
|
||||
/* 4 */
|
||||
COMBA_FORWARD;
|
||||
MULADD(at[0], at[16]); MULADD(at[1], at[15]); MULADD(at[2], at[14]); MULADD(at[3], at[13]); MULADD(at[4], at[12]);
|
||||
COMBA_STORE(C->dp[4]);
|
||||
/* 5 */
|
||||
COMBA_FORWARD;
|
||||
MULADD(at[0], at[17]); MULADD(at[1], at[16]); MULADD(at[2], at[15]); MULADD(at[3], at[14]); MULADD(at[4], at[13]); MULADD(at[5], at[12]);
|
||||
COMBA_STORE(C->dp[5]);
|
||||
/* 6 */
|
||||
COMBA_FORWARD;
|
||||
MULADD(at[0], at[18]); MULADD(at[1], at[17]); MULADD(at[2], at[16]); MULADD(at[3], at[15]); MULADD(at[4], at[14]); MULADD(at[5], at[13]); MULADD(at[6], at[12]);
|
||||
COMBA_STORE(C->dp[6]);
|
||||
/* 7 */
|
||||
COMBA_FORWARD;
|
||||
MULADD(at[0], at[19]); MULADD(at[1], at[18]); MULADD(at[2], at[17]); MULADD(at[3], at[16]); MULADD(at[4], at[15]); MULADD(at[5], at[14]); MULADD(at[6], at[13]); MULADD(at[7], at[12]);
|
||||
COMBA_STORE(C->dp[7]);
|
||||
/* 8 */
|
||||
COMBA_FORWARD;
|
||||
MULADD(at[0], at[20]); MULADD(at[1], at[19]); MULADD(at[2], at[18]); MULADD(at[3], at[17]); MULADD(at[4], at[16]); MULADD(at[5], at[15]); MULADD(at[6], at[14]); MULADD(at[7], at[13]); MULADD(at[8], at[12]);
|
||||
COMBA_STORE(C->dp[8]);
|
||||
/* 9 */
|
||||
COMBA_FORWARD;
|
||||
MULADD(at[0], at[21]); MULADD(at[1], at[20]); MULADD(at[2], at[19]); MULADD(at[3], at[18]); MULADD(at[4], at[17]); MULADD(at[5], at[16]); MULADD(at[6], at[15]); MULADD(at[7], at[14]); MULADD(at[8], at[13]); MULADD(at[9], at[12]);
|
||||
COMBA_STORE(C->dp[9]);
|
||||
/* 10 */
|
||||
COMBA_FORWARD;
|
||||
MULADD(at[0], at[22]); MULADD(at[1], at[21]); MULADD(at[2], at[20]); MULADD(at[3], at[19]); MULADD(at[4], at[18]); MULADD(at[5], at[17]); MULADD(at[6], at[16]); MULADD(at[7], at[15]); MULADD(at[8], at[14]); MULADD(at[9], at[13]); MULADD(at[10], at[12]);
|
||||
COMBA_STORE(C->dp[10]);
|
||||
/* 11 */
|
||||
COMBA_FORWARD;
|
||||
MULADD(at[0], at[23]); MULADD(at[1], at[22]); MULADD(at[2], at[21]); MULADD(at[3], at[20]); MULADD(at[4], at[19]); MULADD(at[5], at[18]); MULADD(at[6], at[17]); MULADD(at[7], at[16]); MULADD(at[8], at[15]); MULADD(at[9], at[14]); MULADD(at[10], at[13]); MULADD(at[11], at[12]);
|
||||
COMBA_STORE(C->dp[11]);
|
||||
/* 12 */
|
||||
COMBA_FORWARD;
|
||||
MULADD(at[1], at[23]); MULADD(at[2], at[22]); MULADD(at[3], at[21]); MULADD(at[4], at[20]); MULADD(at[5], at[19]); MULADD(at[6], at[18]); MULADD(at[7], at[17]); MULADD(at[8], at[16]); MULADD(at[9], at[15]); MULADD(at[10], at[14]); MULADD(at[11], at[13]);
|
||||
COMBA_STORE(C->dp[12]);
|
||||
/* 13 */
|
||||
COMBA_FORWARD;
|
||||
MULADD(at[2], at[23]); MULADD(at[3], at[22]); MULADD(at[4], at[21]); MULADD(at[5], at[20]); MULADD(at[6], at[19]); MULADD(at[7], at[18]); MULADD(at[8], at[17]); MULADD(at[9], at[16]); MULADD(at[10], at[15]); MULADD(at[11], at[14]);
|
||||
COMBA_STORE(C->dp[13]);
|
||||
/* 14 */
|
||||
COMBA_FORWARD;
|
||||
MULADD(at[3], at[23]); MULADD(at[4], at[22]); MULADD(at[5], at[21]); MULADD(at[6], at[20]); MULADD(at[7], at[19]); MULADD(at[8], at[18]); MULADD(at[9], at[17]); MULADD(at[10], at[16]); MULADD(at[11], at[15]);
|
||||
COMBA_STORE(C->dp[14]);
|
||||
/* 15 */
|
||||
COMBA_FORWARD;
|
||||
MULADD(at[4], at[23]); MULADD(at[5], at[22]); MULADD(at[6], at[21]); MULADD(at[7], at[20]); MULADD(at[8], at[19]); MULADD(at[9], at[18]); MULADD(at[10], at[17]); MULADD(at[11], at[16]);
|
||||
COMBA_STORE(C->dp[15]);
|
||||
/* 16 */
|
||||
COMBA_FORWARD;
|
||||
MULADD(at[5], at[23]); MULADD(at[6], at[22]); MULADD(at[7], at[21]); MULADD(at[8], at[20]); MULADD(at[9], at[19]); MULADD(at[10], at[18]); MULADD(at[11], at[17]);
|
||||
COMBA_STORE(C->dp[16]);
|
||||
/* 17 */
|
||||
COMBA_FORWARD;
|
||||
MULADD(at[6], at[23]); MULADD(at[7], at[22]); MULADD(at[8], at[21]); MULADD(at[9], at[20]); MULADD(at[10], at[19]); MULADD(at[11], at[18]);
|
||||
COMBA_STORE(C->dp[17]);
|
||||
/* 18 */
|
||||
COMBA_FORWARD;
|
||||
MULADD(at[7], at[23]); MULADD(at[8], at[22]); MULADD(at[9], at[21]); MULADD(at[10], at[20]); MULADD(at[11], at[19]);
|
||||
COMBA_STORE(C->dp[18]);
|
||||
/* 19 */
|
||||
COMBA_FORWARD;
|
||||
MULADD(at[8], at[23]); MULADD(at[9], at[22]); MULADD(at[10], at[21]); MULADD(at[11], at[20]);
|
||||
COMBA_STORE(C->dp[19]);
|
||||
/* 20 */
|
||||
COMBA_FORWARD;
|
||||
MULADD(at[9], at[23]); MULADD(at[10], at[22]); MULADD(at[11], at[21]);
|
||||
COMBA_STORE(C->dp[20]);
|
||||
/* 21 */
|
||||
COMBA_FORWARD;
|
||||
MULADD(at[10], at[23]); MULADD(at[11], at[22]);
|
||||
COMBA_STORE(C->dp[21]);
|
||||
/* 22 */
|
||||
COMBA_FORWARD;
|
||||
MULADD(at[11], at[23]);
|
||||
COMBA_STORE(C->dp[22]);
|
||||
COMBA_STORE2(C->dp[23]);
|
||||
C->used = 24;
|
||||
C->sign = A->sign ^ B->sign;
|
||||
fp_clamp(C);
|
||||
COMBA_FINI;
|
||||
|
||||
#ifdef WOLFSSL_SMALL_STACK
|
||||
XFREE(at, NULL, DYNAMIC_TYPE_TMP_BUFFER);
|
||||
#endif
|
||||
return FP_OKAY;
|
||||
}
|
||||
#endif
|
@ -1,187 +0,0 @@
|
||||
/* fp_mul_comba_17.i
|
||||
*
|
||||
* Copyright (C) 2006-2020 wolfSSL Inc.
|
||||
*
|
||||
* This file is part of wolfSSL.
|
||||
*
|
||||
* wolfSSL is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* wolfSSL is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA
|
||||
*/
|
||||
|
||||
|
||||
|
||||
#ifdef TFM_MUL17
|
||||
int fp_mul_comba17(fp_int *A, fp_int *B, fp_int *C)
|
||||
{
|
||||
fp_digit c0, c1, c2;
|
||||
#ifndef WOLFSSL_SMALL_STACK
|
||||
fp_digit at[34];
|
||||
#else
|
||||
fp_digit *at;
|
||||
#endif
|
||||
|
||||
#ifdef WOLFSSL_SMALL_STACK
|
||||
at = (fp_digit*)XMALLOC(sizeof(fp_digit) * 34, NULL, DYNAMIC_TYPE_TMP_BUFFER);
|
||||
if (at == NULL)
|
||||
return FP_MEM;
|
||||
#endif
|
||||
|
||||
XMEMCPY(at, A->dp, 17 * sizeof(fp_digit));
|
||||
XMEMCPY(at+17, B->dp, 17 * sizeof(fp_digit));
|
||||
COMBA_START;
|
||||
|
||||
COMBA_CLEAR;
|
||||
/* 0 */
|
||||
MULADD(at[0], at[17]);
|
||||
COMBA_STORE(C->dp[0]);
|
||||
/* 1 */
|
||||
COMBA_FORWARD;
|
||||
MULADD(at[0], at[18]); MULADD(at[1], at[17]);
|
||||
COMBA_STORE(C->dp[1]);
|
||||
/* 2 */
|
||||
COMBA_FORWARD;
|
||||
MULADD(at[0], at[19]); MULADD(at[1], at[18]); MULADD(at[2], at[17]);
|
||||
COMBA_STORE(C->dp[2]);
|
||||
/* 3 */
|
||||
COMBA_FORWARD;
|
||||
MULADD(at[0], at[20]); MULADD(at[1], at[19]); MULADD(at[2], at[18]); MULADD(at[3], at[17]);
|
||||
COMBA_STORE(C->dp[3]);
|
||||
/* 4 */
|
||||
COMBA_FORWARD;
|
||||
MULADD(at[0], at[21]); MULADD(at[1], at[20]); MULADD(at[2], at[19]); MULADD(at[3], at[18]); MULADD(at[4], at[17]);
|
||||
COMBA_STORE(C->dp[4]);
|
||||
/* 5 */
|
||||
COMBA_FORWARD;
|
||||
MULADD(at[0], at[22]); MULADD(at[1], at[21]); MULADD(at[2], at[20]); MULADD(at[3], at[19]); MULADD(at[4], at[18]); MULADD(at[5], at[17]);
|
||||
COMBA_STORE(C->dp[5]);
|
||||
/* 6 */
|
||||
COMBA_FORWARD;
|
||||
MULADD(at[0], at[23]); MULADD(at[1], at[22]); MULADD(at[2], at[21]); MULADD(at[3], at[20]); MULADD(at[4], at[19]); MULADD(at[5], at[18]); MULADD(at[6], at[17]);
|
||||
COMBA_STORE(C->dp[6]);
|
||||
/* 7 */
|
||||
COMBA_FORWARD;
|
||||
MULADD(at[0], at[24]); MULADD(at[1], at[23]); MULADD(at[2], at[22]); MULADD(at[3], at[21]); MULADD(at[4], at[20]); MULADD(at[5], at[19]); MULADD(at[6], at[18]); MULADD(at[7], at[17]);
|
||||
COMBA_STORE(C->dp[7]);
|
||||
/* 8 */
|
||||
COMBA_FORWARD;
|
||||
MULADD(at[0], at[25]); MULADD(at[1], at[24]); MULADD(at[2], at[23]); MULADD(at[3], at[22]); MULADD(at[4], at[21]); MULADD(at[5], at[20]); MULADD(at[6], at[19]); MULADD(at[7], at[18]); MULADD(at[8], at[17]);
|
||||
COMBA_STORE(C->dp[8]);
|
||||
/* 9 */
|
||||
COMBA_FORWARD;
|
||||
MULADD(at[0], at[26]); MULADD(at[1], at[25]); MULADD(at[2], at[24]); MULADD(at[3], at[23]); MULADD(at[4], at[22]); MULADD(at[5], at[21]); MULADD(at[6], at[20]); MULADD(at[7], at[19]); MULADD(at[8], at[18]); MULADD(at[9], at[17]);
|
||||
COMBA_STORE(C->dp[9]);
|
||||
/* 10 */
|
||||
COMBA_FORWARD;
|
||||
MULADD(at[0], at[27]); MULADD(at[1], at[26]); MULADD(at[2], at[25]); MULADD(at[3], at[24]); MULADD(at[4], at[23]); MULADD(at[5], at[22]); MULADD(at[6], at[21]); MULADD(at[7], at[20]); MULADD(at[8], at[19]); MULADD(at[9], at[18]); MULADD(at[10], at[17]);
|
||||
COMBA_STORE(C->dp[10]);
|
||||
/* 11 */
|
||||
COMBA_FORWARD;
|
||||
MULADD(at[0], at[28]); MULADD(at[1], at[27]); MULADD(at[2], at[26]); MULADD(at[3], at[25]); MULADD(at[4], at[24]); MULADD(at[5], at[23]); MULADD(at[6], at[22]); MULADD(at[7], at[21]); MULADD(at[8], at[20]); MULADD(at[9], at[19]); MULADD(at[10], at[18]); MULADD(at[11], at[17]);
|
||||
COMBA_STORE(C->dp[11]);
|
||||
/* 12 */
|
||||
COMBA_FORWARD;
|
||||
MULADD(at[0], at[29]); MULADD(at[1], at[28]); MULADD(at[2], at[27]); MULADD(at[3], at[26]); MULADD(at[4], at[25]); MULADD(at[5], at[24]); MULADD(at[6], at[23]); MULADD(at[7], at[22]); MULADD(at[8], at[21]); MULADD(at[9], at[20]); MULADD(at[10], at[19]); MULADD(at[11], at[18]); MULADD(at[12], at[17]);
|
||||
COMBA_STORE(C->dp[12]);
|
||||
/* 13 */
|
||||
COMBA_FORWARD;
|
||||
MULADD(at[0], at[30]); MULADD(at[1], at[29]); MULADD(at[2], at[28]); MULADD(at[3], at[27]); MULADD(at[4], at[26]); MULADD(at[5], at[25]); MULADD(at[6], at[24]); MULADD(at[7], at[23]); MULADD(at[8], at[22]); MULADD(at[9], at[21]); MULADD(at[10], at[20]); MULADD(at[11], at[19]); MULADD(at[12], at[18]); MULADD(at[13], at[17]);
|
||||
COMBA_STORE(C->dp[13]);
|
||||
/* 14 */
|
||||
COMBA_FORWARD;
|
||||
MULADD(at[0], at[31]); MULADD(at[1], at[30]); MULADD(at[2], at[29]); MULADD(at[3], at[28]); MULADD(at[4], at[27]); MULADD(at[5], at[26]); MULADD(at[6], at[25]); MULADD(at[7], at[24]); MULADD(at[8], at[23]); MULADD(at[9], at[22]); MULADD(at[10], at[21]); MULADD(at[11], at[20]); MULADD(at[12], at[19]); MULADD(at[13], at[18]); MULADD(at[14], at[17]);
|
||||
COMBA_STORE(C->dp[14]);
|
||||
/* 15 */
|
||||
COMBA_FORWARD;
|
||||
MULADD(at[0], at[32]); MULADD(at[1], at[31]); MULADD(at[2], at[30]); MULADD(at[3], at[29]); MULADD(at[4], at[28]); MULADD(at[5], at[27]); MULADD(at[6], at[26]); MULADD(at[7], at[25]); MULADD(at[8], at[24]); MULADD(at[9], at[23]); MULADD(at[10], at[22]); MULADD(at[11], at[21]); MULADD(at[12], at[20]); MULADD(at[13], at[19]); MULADD(at[14], at[18]); MULADD(at[15], at[17]);
|
||||
COMBA_STORE(C->dp[15]);
|
||||
/* 16 */
|
||||
COMBA_FORWARD;
|
||||
MULADD(at[0], at[33]); MULADD(at[1], at[32]); MULADD(at[2], at[31]); MULADD(at[3], at[30]); MULADD(at[4], at[29]); MULADD(at[5], at[28]); MULADD(at[6], at[27]); MULADD(at[7], at[26]); MULADD(at[8], at[25]); MULADD(at[9], at[24]); MULADD(at[10], at[23]); MULADD(at[11], at[22]); MULADD(at[12], at[21]); MULADD(at[13], at[20]); MULADD(at[14], at[19]); MULADD(at[15], at[18]); MULADD(at[16], at[17]);
|
||||
COMBA_STORE(C->dp[16]);
|
||||
/* 17 */
|
||||
COMBA_FORWARD;
|
||||
MULADD(at[1], at[33]); MULADD(at[2], at[32]); MULADD(at[3], at[31]); MULADD(at[4], at[30]); MULADD(at[5], at[29]); MULADD(at[6], at[28]); MULADD(at[7], at[27]); MULADD(at[8], at[26]); MULADD(at[9], at[25]); MULADD(at[10], at[24]); MULADD(at[11], at[23]); MULADD(at[12], at[22]); MULADD(at[13], at[21]); MULADD(at[14], at[20]); MULADD(at[15], at[19]); MULADD(at[16], at[18]);
|
||||
COMBA_STORE(C->dp[17]);
|
||||
/* 18 */
|
||||
COMBA_FORWARD;
|
||||
MULADD(at[2], at[33]); MULADD(at[3], at[32]); MULADD(at[4], at[31]); MULADD(at[5], at[30]); MULADD(at[6], at[29]); MULADD(at[7], at[28]); MULADD(at[8], at[27]); MULADD(at[9], at[26]); MULADD(at[10], at[25]); MULADD(at[11], at[24]); MULADD(at[12], at[23]); MULADD(at[13], at[22]); MULADD(at[14], at[21]); MULADD(at[15], at[20]); MULADD(at[16], at[19]);
|
||||
COMBA_STORE(C->dp[18]);
|
||||
/* 19 */
|
||||
COMBA_FORWARD;
|
||||
MULADD(at[3], at[33]); MULADD(at[4], at[32]); MULADD(at[5], at[31]); MULADD(at[6], at[30]); MULADD(at[7], at[29]); MULADD(at[8], at[28]); MULADD(at[9], at[27]); MULADD(at[10], at[26]); MULADD(at[11], at[25]); MULADD(at[12], at[24]); MULADD(at[13], at[23]); MULADD(at[14], at[22]); MULADD(at[15], at[21]); MULADD(at[16], at[20]);
|
||||
COMBA_STORE(C->dp[19]);
|
||||
/* 20 */
|
||||
COMBA_FORWARD;
|
||||
MULADD(at[4], at[33]); MULADD(at[5], at[32]); MULADD(at[6], at[31]); MULADD(at[7], at[30]); MULADD(at[8], at[29]); MULADD(at[9], at[28]); MULADD(at[10], at[27]); MULADD(at[11], at[26]); MULADD(at[12], at[25]); MULADD(at[13], at[24]); MULADD(at[14], at[23]); MULADD(at[15], at[22]); MULADD(at[16], at[21]);
|
||||
COMBA_STORE(C->dp[20]);
|
||||
/* 21 */
|
||||
COMBA_FORWARD;
|
||||
MULADD(at[5], at[33]); MULADD(at[6], at[32]); MULADD(at[7], at[31]); MULADD(at[8], at[30]); MULADD(at[9], at[29]); MULADD(at[10], at[28]); MULADD(at[11], at[27]); MULADD(at[12], at[26]); MULADD(at[13], at[25]); MULADD(at[14], at[24]); MULADD(at[15], at[23]); MULADD(at[16], at[22]);
|
||||
COMBA_STORE(C->dp[21]);
|
||||
/* 22 */
|
||||
COMBA_FORWARD;
|
||||
MULADD(at[6], at[33]); MULADD(at[7], at[32]); MULADD(at[8], at[31]); MULADD(at[9], at[30]); MULADD(at[10], at[29]); MULADD(at[11], at[28]); MULADD(at[12], at[27]); MULADD(at[13], at[26]); MULADD(at[14], at[25]); MULADD(at[15], at[24]); MULADD(at[16], at[23]);
|
||||
COMBA_STORE(C->dp[22]);
|
||||
/* 23 */
|
||||
COMBA_FORWARD;
|
||||
MULADD(at[7], at[33]); MULADD(at[8], at[32]); MULADD(at[9], at[31]); MULADD(at[10], at[30]); MULADD(at[11], at[29]); MULADD(at[12], at[28]); MULADD(at[13], at[27]); MULADD(at[14], at[26]); MULADD(at[15], at[25]); MULADD(at[16], at[24]);
|
||||
COMBA_STORE(C->dp[23]);
|
||||
/* 24 */
|
||||
COMBA_FORWARD;
|
||||
MULADD(at[8], at[33]); MULADD(at[9], at[32]); MULADD(at[10], at[31]); MULADD(at[11], at[30]); MULADD(at[12], at[29]); MULADD(at[13], at[28]); MULADD(at[14], at[27]); MULADD(at[15], at[26]); MULADD(at[16], at[25]);
|
||||
COMBA_STORE(C->dp[24]);
|
||||
/* 25 */
|
||||
COMBA_FORWARD;
|
||||
MULADD(at[9], at[33]); MULADD(at[10], at[32]); MULADD(at[11], at[31]); MULADD(at[12], at[30]); MULADD(at[13], at[29]); MULADD(at[14], at[28]); MULADD(at[15], at[27]); MULADD(at[16], at[26]);
|
||||
COMBA_STORE(C->dp[25]);
|
||||
/* 26 */
|
||||
COMBA_FORWARD;
|
||||
MULADD(at[10], at[33]); MULADD(at[11], at[32]); MULADD(at[12], at[31]); MULADD(at[13], at[30]); MULADD(at[14], at[29]); MULADD(at[15], at[28]); MULADD(at[16], at[27]);
|
||||
COMBA_STORE(C->dp[26]);
|
||||
/* 27 */
|
||||
COMBA_FORWARD;
|
||||
MULADD(at[11], at[33]); MULADD(at[12], at[32]); MULADD(at[13], at[31]); MULADD(at[14], at[30]); MULADD(at[15], at[29]); MULADD(at[16], at[28]);
|
||||
COMBA_STORE(C->dp[27]);
|
||||
/* 28 */
|
||||
COMBA_FORWARD;
|
||||
MULADD(at[12], at[33]); MULADD(at[13], at[32]); MULADD(at[14], at[31]); MULADD(at[15], at[30]); MULADD(at[16], at[29]);
|
||||
COMBA_STORE(C->dp[28]);
|
||||
/* 29 */
|
||||
COMBA_FORWARD;
|
||||
MULADD(at[13], at[33]); MULADD(at[14], at[32]); MULADD(at[15], at[31]); MULADD(at[16], at[30]);
|
||||
COMBA_STORE(C->dp[29]);
|
||||
/* 30 */
|
||||
COMBA_FORWARD;
|
||||
MULADD(at[14], at[33]); MULADD(at[15], at[32]); MULADD(at[16], at[31]);
|
||||
COMBA_STORE(C->dp[30]);
|
||||
/* 31 */
|
||||
COMBA_FORWARD;
|
||||
MULADD(at[15], at[33]); MULADD(at[16], at[32]);
|
||||
COMBA_STORE(C->dp[31]);
|
||||
/* 32 */
|
||||
COMBA_FORWARD;
|
||||
MULADD(at[16], at[33]);
|
||||
COMBA_STORE(C->dp[32]);
|
||||
COMBA_STORE2(C->dp[33]);
|
||||
C->used = 34;
|
||||
C->sign = A->sign ^ B->sign;
|
||||
fp_clamp(C);
|
||||
COMBA_FINI;
|
||||
|
||||
#ifdef WOLFSSL_SMALL_STACK
|
||||
XFREE(at, NULL, DYNAMIC_TYPE_TMP_BUFFER);
|
||||
#endif
|
||||
return FP_OKAY;
|
||||
}
|
||||
#endif
|
@ -1,210 +0,0 @@
|
||||
/* fp_mul_comba_20.i
|
||||
*
|
||||
* Copyright (C) 2006-2020 wolfSSL Inc.
|
||||
*
|
||||
* This file is part of wolfSSL.
|
||||
*
|
||||
* wolfSSL is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* wolfSSL is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA
|
||||
*/
|
||||
|
||||
|
||||
#ifdef TFM_MUL20
|
||||
int fp_mul_comba20(fp_int *A, fp_int *B, fp_int *C)
|
||||
{
|
||||
fp_digit c0, c1, c2;
|
||||
#ifndef WOLFSSL_SMALL_STACK
|
||||
fp_digit at[40];
|
||||
#else
|
||||
fp_digit *at;
|
||||
#endif
|
||||
|
||||
#ifdef WOLFSSL_SMALL_STACK
|
||||
at = (fp_digit*)XMALLOC(sizeof(fp_digit) * 40, NULL, DYNAMIC_TYPE_TMP_BUFFER);
|
||||
if (at == NULL)
|
||||
return FP_MEM;
|
||||
#endif
|
||||
|
||||
XMEMCPY(at, A->dp, 20 * sizeof(fp_digit));
|
||||
XMEMCPY(at+20, B->dp, 20 * sizeof(fp_digit));
|
||||
COMBA_START;
|
||||
|
||||
COMBA_CLEAR;
|
||||
/* 0 */
|
||||
MULADD(at[0], at[20]);
|
||||
COMBA_STORE(C->dp[0]);
|
||||
/* 1 */
|
||||
COMBA_FORWARD;
|
||||
MULADD(at[0], at[21]); MULADD(at[1], at[20]);
|
||||
COMBA_STORE(C->dp[1]);
|
||||
/* 2 */
|
||||
COMBA_FORWARD;
|
||||
MULADD(at[0], at[22]); MULADD(at[1], at[21]); MULADD(at[2], at[20]);
|
||||
COMBA_STORE(C->dp[2]);
|
||||
/* 3 */
|
||||
COMBA_FORWARD;
|
||||
MULADD(at[0], at[23]); MULADD(at[1], at[22]); MULADD(at[2], at[21]); MULADD(at[3], at[20]);
|
||||
COMBA_STORE(C->dp[3]);
|
||||
/* 4 */
|
||||
COMBA_FORWARD;
|
||||
MULADD(at[0], at[24]); MULADD(at[1], at[23]); MULADD(at[2], at[22]); MULADD(at[3], at[21]); MULADD(at[4], at[20]);
|
||||
COMBA_STORE(C->dp[4]);
|
||||
/* 5 */
|
||||
COMBA_FORWARD;
|
||||
MULADD(at[0], at[25]); MULADD(at[1], at[24]); MULADD(at[2], at[23]); MULADD(at[3], at[22]); MULADD(at[4], at[21]); MULADD(at[5], at[20]);
|
||||
COMBA_STORE(C->dp[5]);
|
||||
/* 6 */
|
||||
COMBA_FORWARD;
|
||||
MULADD(at[0], at[26]); MULADD(at[1], at[25]); MULADD(at[2], at[24]); MULADD(at[3], at[23]); MULADD(at[4], at[22]); MULADD(at[5], at[21]); MULADD(at[6], at[20]);
|
||||
COMBA_STORE(C->dp[6]);
|
||||
/* 7 */
|
||||
COMBA_FORWARD;
|
||||
MULADD(at[0], at[27]); MULADD(at[1], at[26]); MULADD(at[2], at[25]); MULADD(at[3], at[24]); MULADD(at[4], at[23]); MULADD(at[5], at[22]); MULADD(at[6], at[21]); MULADD(at[7], at[20]);
|
||||
COMBA_STORE(C->dp[7]);
|
||||
/* 8 */
|
||||
COMBA_FORWARD;
|
||||
MULADD(at[0], at[28]); MULADD(at[1], at[27]); MULADD(at[2], at[26]); MULADD(at[3], at[25]); MULADD(at[4], at[24]); MULADD(at[5], at[23]); MULADD(at[6], at[22]); MULADD(at[7], at[21]); MULADD(at[8], at[20]);
|
||||
COMBA_STORE(C->dp[8]);
|
||||
/* 9 */
|
||||
COMBA_FORWARD;
|
||||
MULADD(at[0], at[29]); MULADD(at[1], at[28]); MULADD(at[2], at[27]); MULADD(at[3], at[26]); MULADD(at[4], at[25]); MULADD(at[5], at[24]); MULADD(at[6], at[23]); MULADD(at[7], at[22]); MULADD(at[8], at[21]); MULADD(at[9], at[20]);
|
||||
COMBA_STORE(C->dp[9]);
|
||||
/* 10 */
|
||||
COMBA_FORWARD;
|
||||
MULADD(at[0], at[30]); MULADD(at[1], at[29]); MULADD(at[2], at[28]); MULADD(at[3], at[27]); MULADD(at[4], at[26]); MULADD(at[5], at[25]); MULADD(at[6], at[24]); MULADD(at[7], at[23]); MULADD(at[8], at[22]); MULADD(at[9], at[21]); MULADD(at[10], at[20]);
|
||||
COMBA_STORE(C->dp[10]);
|
||||
/* 11 */
|
||||
COMBA_FORWARD;
|
||||
MULADD(at[0], at[31]); MULADD(at[1], at[30]); MULADD(at[2], at[29]); MULADD(at[3], at[28]); MULADD(at[4], at[27]); MULADD(at[5], at[26]); MULADD(at[6], at[25]); MULADD(at[7], at[24]); MULADD(at[8], at[23]); MULADD(at[9], at[22]); MULADD(at[10], at[21]); MULADD(at[11], at[20]);
|
||||
COMBA_STORE(C->dp[11]);
|
||||
/* 12 */
|
||||
COMBA_FORWARD;
|
||||
MULADD(at[0], at[32]); MULADD(at[1], at[31]); MULADD(at[2], at[30]); MULADD(at[3], at[29]); MULADD(at[4], at[28]); MULADD(at[5], at[27]); MULADD(at[6], at[26]); MULADD(at[7], at[25]); MULADD(at[8], at[24]); MULADD(at[9], at[23]); MULADD(at[10], at[22]); MULADD(at[11], at[21]); MULADD(at[12], at[20]);
|
||||
COMBA_STORE(C->dp[12]);
|
||||
/* 13 */
|
||||
COMBA_FORWARD;
|
||||
MULADD(at[0], at[33]); MULADD(at[1], at[32]); MULADD(at[2], at[31]); MULADD(at[3], at[30]); MULADD(at[4], at[29]); MULADD(at[5], at[28]); MULADD(at[6], at[27]); MULADD(at[7], at[26]); MULADD(at[8], at[25]); MULADD(at[9], at[24]); MULADD(at[10], at[23]); MULADD(at[11], at[22]); MULADD(at[12], at[21]); MULADD(at[13], at[20]);
|
||||
COMBA_STORE(C->dp[13]);
|
||||
/* 14 */
|
||||
COMBA_FORWARD;
|
||||
MULADD(at[0], at[34]); MULADD(at[1], at[33]); MULADD(at[2], at[32]); MULADD(at[3], at[31]); MULADD(at[4], at[30]); MULADD(at[5], at[29]); MULADD(at[6], at[28]); MULADD(at[7], at[27]); MULADD(at[8], at[26]); MULADD(at[9], at[25]); MULADD(at[10], at[24]); MULADD(at[11], at[23]); MULADD(at[12], at[22]); MULADD(at[13], at[21]); MULADD(at[14], at[20]);
|
||||
COMBA_STORE(C->dp[14]);
|
||||
/* 15 */
|
||||
COMBA_FORWARD;
|
||||
MULADD(at[0], at[35]); MULADD(at[1], at[34]); MULADD(at[2], at[33]); MULADD(at[3], at[32]); MULADD(at[4], at[31]); MULADD(at[5], at[30]); MULADD(at[6], at[29]); MULADD(at[7], at[28]); MULADD(at[8], at[27]); MULADD(at[9], at[26]); MULADD(at[10], at[25]); MULADD(at[11], at[24]); MULADD(at[12], at[23]); MULADD(at[13], at[22]); MULADD(at[14], at[21]); MULADD(at[15], at[20]);
|
||||
COMBA_STORE(C->dp[15]);
|
||||
/* 16 */
|
||||
COMBA_FORWARD;
|
||||
MULADD(at[0], at[36]); MULADD(at[1], at[35]); MULADD(at[2], at[34]); MULADD(at[3], at[33]); MULADD(at[4], at[32]); MULADD(at[5], at[31]); MULADD(at[6], at[30]); MULADD(at[7], at[29]); MULADD(at[8], at[28]); MULADD(at[9], at[27]); MULADD(at[10], at[26]); MULADD(at[11], at[25]); MULADD(at[12], at[24]); MULADD(at[13], at[23]); MULADD(at[14], at[22]); MULADD(at[15], at[21]); MULADD(at[16], at[20]);
|
||||
COMBA_STORE(C->dp[16]);
|
||||
/* 17 */
|
||||
COMBA_FORWARD;
|
||||
MULADD(at[0], at[37]); MULADD(at[1], at[36]); MULADD(at[2], at[35]); MULADD(at[3], at[34]); MULADD(at[4], at[33]); MULADD(at[5], at[32]); MULADD(at[6], at[31]); MULADD(at[7], at[30]); MULADD(at[8], at[29]); MULADD(at[9], at[28]); MULADD(at[10], at[27]); MULADD(at[11], at[26]); MULADD(at[12], at[25]); MULADD(at[13], at[24]); MULADD(at[14], at[23]); MULADD(at[15], at[22]); MULADD(at[16], at[21]); MULADD(at[17], at[20]);
|
||||
COMBA_STORE(C->dp[17]);
|
||||
/* 18 */
|
||||
COMBA_FORWARD;
|
||||
MULADD(at[0], at[38]); MULADD(at[1], at[37]); MULADD(at[2], at[36]); MULADD(at[3], at[35]); MULADD(at[4], at[34]); MULADD(at[5], at[33]); MULADD(at[6], at[32]); MULADD(at[7], at[31]); MULADD(at[8], at[30]); MULADD(at[9], at[29]); MULADD(at[10], at[28]); MULADD(at[11], at[27]); MULADD(at[12], at[26]); MULADD(at[13], at[25]); MULADD(at[14], at[24]); MULADD(at[15], at[23]); MULADD(at[16], at[22]); MULADD(at[17], at[21]); MULADD(at[18], at[20]);
|
||||
COMBA_STORE(C->dp[18]);
|
||||
/* 19 */
|
||||
COMBA_FORWARD;
|
||||
MULADD(at[0], at[39]); MULADD(at[1], at[38]); MULADD(at[2], at[37]); MULADD(at[3], at[36]); MULADD(at[4], at[35]); MULADD(at[5], at[34]); MULADD(at[6], at[33]); MULADD(at[7], at[32]); MULADD(at[8], at[31]); MULADD(at[9], at[30]); MULADD(at[10], at[29]); MULADD(at[11], at[28]); MULADD(at[12], at[27]); MULADD(at[13], at[26]); MULADD(at[14], at[25]); MULADD(at[15], at[24]); MULADD(at[16], at[23]); MULADD(at[17], at[22]); MULADD(at[18], at[21]); MULADD(at[19], at[20]);
|
||||
COMBA_STORE(C->dp[19]);
|
||||
/* 20 */
|
||||
COMBA_FORWARD;
|
||||
MULADD(at[1], at[39]); MULADD(at[2], at[38]); MULADD(at[3], at[37]); MULADD(at[4], at[36]); MULADD(at[5], at[35]); MULADD(at[6], at[34]); MULADD(at[7], at[33]); MULADD(at[8], at[32]); MULADD(at[9], at[31]); MULADD(at[10], at[30]); MULADD(at[11], at[29]); MULADD(at[12], at[28]); MULADD(at[13], at[27]); MULADD(at[14], at[26]); MULADD(at[15], at[25]); MULADD(at[16], at[24]); MULADD(at[17], at[23]); MULADD(at[18], at[22]); MULADD(at[19], at[21]);
|
||||
COMBA_STORE(C->dp[20]);
|
||||
/* 21 */
|
||||
COMBA_FORWARD;
|
||||
MULADD(at[2], at[39]); MULADD(at[3], at[38]); MULADD(at[4], at[37]); MULADD(at[5], at[36]); MULADD(at[6], at[35]); MULADD(at[7], at[34]); MULADD(at[8], at[33]); MULADD(at[9], at[32]); MULADD(at[10], at[31]); MULADD(at[11], at[30]); MULADD(at[12], at[29]); MULADD(at[13], at[28]); MULADD(at[14], at[27]); MULADD(at[15], at[26]); MULADD(at[16], at[25]); MULADD(at[17], at[24]); MULADD(at[18], at[23]); MULADD(at[19], at[22]);
|
||||
COMBA_STORE(C->dp[21]);
|
||||
/* 22 */
|
||||
COMBA_FORWARD;
|
||||
MULADD(at[3], at[39]); MULADD(at[4], at[38]); MULADD(at[5], at[37]); MULADD(at[6], at[36]); MULADD(at[7], at[35]); MULADD(at[8], at[34]); MULADD(at[9], at[33]); MULADD(at[10], at[32]); MULADD(at[11], at[31]); MULADD(at[12], at[30]); MULADD(at[13], at[29]); MULADD(at[14], at[28]); MULADD(at[15], at[27]); MULADD(at[16], at[26]); MULADD(at[17], at[25]); MULADD(at[18], at[24]); MULADD(at[19], at[23]);
|
||||
COMBA_STORE(C->dp[22]);
|
||||
/* 23 */
|
||||
COMBA_FORWARD;
|
||||
MULADD(at[4], at[39]); MULADD(at[5], at[38]); MULADD(at[6], at[37]); MULADD(at[7], at[36]); MULADD(at[8], at[35]); MULADD(at[9], at[34]); MULADD(at[10], at[33]); MULADD(at[11], at[32]); MULADD(at[12], at[31]); MULADD(at[13], at[30]); MULADD(at[14], at[29]); MULADD(at[15], at[28]); MULADD(at[16], at[27]); MULADD(at[17], at[26]); MULADD(at[18], at[25]); MULADD(at[19], at[24]);
|
||||
COMBA_STORE(C->dp[23]);
|
||||
/* 24 */
|
||||
COMBA_FORWARD;
|
||||
MULADD(at[5], at[39]); MULADD(at[6], at[38]); MULADD(at[7], at[37]); MULADD(at[8], at[36]); MULADD(at[9], at[35]); MULADD(at[10], at[34]); MULADD(at[11], at[33]); MULADD(at[12], at[32]); MULADD(at[13], at[31]); MULADD(at[14], at[30]); MULADD(at[15], at[29]); MULADD(at[16], at[28]); MULADD(at[17], at[27]); MULADD(at[18], at[26]); MULADD(at[19], at[25]);
|
||||
COMBA_STORE(C->dp[24]);
|
||||
/* 25 */
|
||||
COMBA_FORWARD;
|
||||
MULADD(at[6], at[39]); MULADD(at[7], at[38]); MULADD(at[8], at[37]); MULADD(at[9], at[36]); MULADD(at[10], at[35]); MULADD(at[11], at[34]); MULADD(at[12], at[33]); MULADD(at[13], at[32]); MULADD(at[14], at[31]); MULADD(at[15], at[30]); MULADD(at[16], at[29]); MULADD(at[17], at[28]); MULADD(at[18], at[27]); MULADD(at[19], at[26]);
|
||||
COMBA_STORE(C->dp[25]);
|
||||
/* 26 */
|
||||
COMBA_FORWARD;
|
||||
MULADD(at[7], at[39]); MULADD(at[8], at[38]); MULADD(at[9], at[37]); MULADD(at[10], at[36]); MULADD(at[11], at[35]); MULADD(at[12], at[34]); MULADD(at[13], at[33]); MULADD(at[14], at[32]); MULADD(at[15], at[31]); MULADD(at[16], at[30]); MULADD(at[17], at[29]); MULADD(at[18], at[28]); MULADD(at[19], at[27]);
|
||||
COMBA_STORE(C->dp[26]);
|
||||
/* 27 */
|
||||
COMBA_FORWARD;
|
||||
MULADD(at[8], at[39]); MULADD(at[9], at[38]); MULADD(at[10], at[37]); MULADD(at[11], at[36]); MULADD(at[12], at[35]); MULADD(at[13], at[34]); MULADD(at[14], at[33]); MULADD(at[15], at[32]); MULADD(at[16], at[31]); MULADD(at[17], at[30]); MULADD(at[18], at[29]); MULADD(at[19], at[28]);
|
||||
COMBA_STORE(C->dp[27]);
|
||||
/* 28 */
|
||||
COMBA_FORWARD;
|
||||
MULADD(at[9], at[39]); MULADD(at[10], at[38]); MULADD(at[11], at[37]); MULADD(at[12], at[36]); MULADD(at[13], at[35]); MULADD(at[14], at[34]); MULADD(at[15], at[33]); MULADD(at[16], at[32]); MULADD(at[17], at[31]); MULADD(at[18], at[30]); MULADD(at[19], at[29]);
|
||||
COMBA_STORE(C->dp[28]);
|
||||
/* 29 */
|
||||
COMBA_FORWARD;
|
||||
MULADD(at[10], at[39]); MULADD(at[11], at[38]); MULADD(at[12], at[37]); MULADD(at[13], at[36]); MULADD(at[14], at[35]); MULADD(at[15], at[34]); MULADD(at[16], at[33]); MULADD(at[17], at[32]); MULADD(at[18], at[31]); MULADD(at[19], at[30]);
|
||||
COMBA_STORE(C->dp[29]);
|
||||
/* 30 */
|
||||
COMBA_FORWARD;
|
||||
MULADD(at[11], at[39]); MULADD(at[12], at[38]); MULADD(at[13], at[37]); MULADD(at[14], at[36]); MULADD(at[15], at[35]); MULADD(at[16], at[34]); MULADD(at[17], at[33]); MULADD(at[18], at[32]); MULADD(at[19], at[31]);
|
||||
COMBA_STORE(C->dp[30]);
|
||||
/* 31 */
|
||||
COMBA_FORWARD;
|
||||
MULADD(at[12], at[39]); MULADD(at[13], at[38]); MULADD(at[14], at[37]); MULADD(at[15], at[36]); MULADD(at[16], at[35]); MULADD(at[17], at[34]); MULADD(at[18], at[33]); MULADD(at[19], at[32]);
|
||||
COMBA_STORE(C->dp[31]);
|
||||
/* 32 */
|
||||
COMBA_FORWARD;
|
||||
MULADD(at[13], at[39]); MULADD(at[14], at[38]); MULADD(at[15], at[37]); MULADD(at[16], at[36]); MULADD(at[17], at[35]); MULADD(at[18], at[34]); MULADD(at[19], at[33]);
|
||||
COMBA_STORE(C->dp[32]);
|
||||
/* 33 */
|
||||
COMBA_FORWARD;
|
||||
MULADD(at[14], at[39]); MULADD(at[15], at[38]); MULADD(at[16], at[37]); MULADD(at[17], at[36]); MULADD(at[18], at[35]); MULADD(at[19], at[34]);
|
||||
COMBA_STORE(C->dp[33]);
|
||||
/* 34 */
|
||||
COMBA_FORWARD;
|
||||
MULADD(at[15], at[39]); MULADD(at[16], at[38]); MULADD(at[17], at[37]); MULADD(at[18], at[36]); MULADD(at[19], at[35]);
|
||||
COMBA_STORE(C->dp[34]);
|
||||
/* 35 */
|
||||
COMBA_FORWARD;
|
||||
MULADD(at[16], at[39]); MULADD(at[17], at[38]); MULADD(at[18], at[37]); MULADD(at[19], at[36]);
|
||||
COMBA_STORE(C->dp[35]);
|
||||
/* 36 */
|
||||
COMBA_FORWARD;
|
||||
MULADD(at[17], at[39]); MULADD(at[18], at[38]); MULADD(at[19], at[37]);
|
||||
COMBA_STORE(C->dp[36]);
|
||||
/* 37 */
|
||||
COMBA_FORWARD;
|
||||
MULADD(at[18], at[39]); MULADD(at[19], at[38]);
|
||||
COMBA_STORE(C->dp[37]);
|
||||
/* 38 */
|
||||
COMBA_FORWARD;
|
||||
MULADD(at[19], at[39]);
|
||||
COMBA_STORE(C->dp[38]);
|
||||
COMBA_STORE2(C->dp[39]);
|
||||
C->used = 40;
|
||||
C->sign = A->sign ^ B->sign;
|
||||
fp_clamp(C);
|
||||
COMBA_FINI;
|
||||
|
||||
#ifdef WOLFSSL_SMALL_STACK
|
||||
XFREE(at, NULL, DYNAMIC_TYPE_TMP_BUFFER);
|
||||
#endif
|
||||
return FP_OKAY;
|
||||
}
|
||||
#endif
|
@ -1,243 +0,0 @@
|
||||
/* fp_mul_comba_24.i
|
||||
*
|
||||
* Copyright (C) 2006-2020 wolfSSL Inc.
|
||||
*
|
||||
* This file is part of wolfSSL.
|
||||
*
|
||||
* wolfSSL is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* wolfSSL is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA
|
||||
*/
|
||||
|
||||
|
||||
|
||||
#ifdef TFM_MUL24
|
||||
int fp_mul_comba24(fp_int *A, fp_int *B, fp_int *C)
|
||||
{
|
||||
fp_digit c0, c1, c2;
|
||||
#ifndef WOLFSSL_SMALL_STACK
|
||||
fp_digit at[48];
|
||||
#else
|
||||
fp_digit *at;
|
||||
#endif
|
||||
|
||||
#ifdef WOLFSSL_SMALL_STACK
|
||||
at = (fp_digit*)XMALLOC(sizeof(fp_digit) * 48, NULL, DYNAMIC_TYPE_TMP_BUFFER);
|
||||
if (at == NULL)
|
||||
return FP_MEM;
|
||||
#endif
|
||||
|
||||
XMEMCPY(at, A->dp, 24 * sizeof(fp_digit));
|
||||
XMEMCPY(at+24, B->dp, 24 * sizeof(fp_digit));
|
||||
COMBA_START;
|
||||
|
||||
COMBA_CLEAR;
|
||||
/* 0 */
|
||||
MULADD(at[0], at[24]);
|
||||
COMBA_STORE(C->dp[0]);
|
||||
/* 1 */
|
||||
COMBA_FORWARD;
|
||||
MULADD(at[0], at[25]); MULADD(at[1], at[24]);
|
||||
COMBA_STORE(C->dp[1]);
|
||||
/* 2 */
|
||||
COMBA_FORWARD;
|
||||
MULADD(at[0], at[26]); MULADD(at[1], at[25]); MULADD(at[2], at[24]);
|
||||
COMBA_STORE(C->dp[2]);
|
||||
/* 3 */
|
||||
COMBA_FORWARD;
|
||||
MULADD(at[0], at[27]); MULADD(at[1], at[26]); MULADD(at[2], at[25]); MULADD(at[3], at[24]);
|
||||
COMBA_STORE(C->dp[3]);
|
||||
/* 4 */
|
||||
COMBA_FORWARD;
|
||||
MULADD(at[0], at[28]); MULADD(at[1], at[27]); MULADD(at[2], at[26]); MULADD(at[3], at[25]); MULADD(at[4], at[24]);
|
||||
COMBA_STORE(C->dp[4]);
|
||||
/* 5 */
|
||||
COMBA_FORWARD;
|
||||
MULADD(at[0], at[29]); MULADD(at[1], at[28]); MULADD(at[2], at[27]); MULADD(at[3], at[26]); MULADD(at[4], at[25]); MULADD(at[5], at[24]);
|
||||
COMBA_STORE(C->dp[5]);
|
||||
/* 6 */
|
||||
COMBA_FORWARD;
|
||||
MULADD(at[0], at[30]); MULADD(at[1], at[29]); MULADD(at[2], at[28]); MULADD(at[3], at[27]); MULADD(at[4], at[26]); MULADD(at[5], at[25]); MULADD(at[6], at[24]);
|
||||
COMBA_STORE(C->dp[6]);
|
||||
/* 7 */
|
||||
COMBA_FORWARD;
|
||||
MULADD(at[0], at[31]); MULADD(at[1], at[30]); MULADD(at[2], at[29]); MULADD(at[3], at[28]); MULADD(at[4], at[27]); MULADD(at[5], at[26]); MULADD(at[6], at[25]); MULADD(at[7], at[24]);
|
||||
COMBA_STORE(C->dp[7]);
|
||||
/* 8 */
|
||||
COMBA_FORWARD;
|
||||
MULADD(at[0], at[32]); MULADD(at[1], at[31]); MULADD(at[2], at[30]); MULADD(at[3], at[29]); MULADD(at[4], at[28]); MULADD(at[5], at[27]); MULADD(at[6], at[26]); MULADD(at[7], at[25]); MULADD(at[8], at[24]);
|
||||
COMBA_STORE(C->dp[8]);
|
||||
/* 9 */
|
||||
COMBA_FORWARD;
|
||||
MULADD(at[0], at[33]); MULADD(at[1], at[32]); MULADD(at[2], at[31]); MULADD(at[3], at[30]); MULADD(at[4], at[29]); MULADD(at[5], at[28]); MULADD(at[6], at[27]); MULADD(at[7], at[26]); MULADD(at[8], at[25]); MULADD(at[9], at[24]);
|
||||
COMBA_STORE(C->dp[9]);
|
||||
/* 10 */
|
||||
COMBA_FORWARD;
|
||||
MULADD(at[0], at[34]); MULADD(at[1], at[33]); MULADD(at[2], at[32]); MULADD(at[3], at[31]); MULADD(at[4], at[30]); MULADD(at[5], at[29]); MULADD(at[6], at[28]); MULADD(at[7], at[27]); MULADD(at[8], at[26]); MULADD(at[9], at[25]); MULADD(at[10], at[24]);
|
||||
COMBA_STORE(C->dp[10]);
|
||||
/* 11 */
|
||||
COMBA_FORWARD;
|
||||
MULADD(at[0], at[35]); MULADD(at[1], at[34]); MULADD(at[2], at[33]); MULADD(at[3], at[32]); MULADD(at[4], at[31]); MULADD(at[5], at[30]); MULADD(at[6], at[29]); MULADD(at[7], at[28]); MULADD(at[8], at[27]); MULADD(at[9], at[26]); MULADD(at[10], at[25]); MULADD(at[11], at[24]);
|
||||
COMBA_STORE(C->dp[11]);
|
||||
/* 12 */
|
||||
COMBA_FORWARD;
|
||||
MULADD(at[0], at[36]); MULADD(at[1], at[35]); MULADD(at[2], at[34]); MULADD(at[3], at[33]); MULADD(at[4], at[32]); MULADD(at[5], at[31]); MULADD(at[6], at[30]); MULADD(at[7], at[29]); MULADD(at[8], at[28]); MULADD(at[9], at[27]); MULADD(at[10], at[26]); MULADD(at[11], at[25]); MULADD(at[12], at[24]);
|
||||
COMBA_STORE(C->dp[12]);
|
||||
/* 13 */
|
||||
COMBA_FORWARD;
|
||||
MULADD(at[0], at[37]); MULADD(at[1], at[36]); MULADD(at[2], at[35]); MULADD(at[3], at[34]); MULADD(at[4], at[33]); MULADD(at[5], at[32]); MULADD(at[6], at[31]); MULADD(at[7], at[30]); MULADD(at[8], at[29]); MULADD(at[9], at[28]); MULADD(at[10], at[27]); MULADD(at[11], at[26]); MULADD(at[12], at[25]); MULADD(at[13], at[24]);
|
||||
COMBA_STORE(C->dp[13]);
|
||||
/* 14 */
|
||||
COMBA_FORWARD;
|
||||
MULADD(at[0], at[38]); MULADD(at[1], at[37]); MULADD(at[2], at[36]); MULADD(at[3], at[35]); MULADD(at[4], at[34]); MULADD(at[5], at[33]); MULADD(at[6], at[32]); MULADD(at[7], at[31]); MULADD(at[8], at[30]); MULADD(at[9], at[29]); MULADD(at[10], at[28]); MULADD(at[11], at[27]); MULADD(at[12], at[26]); MULADD(at[13], at[25]); MULADD(at[14], at[24]);
|
||||
COMBA_STORE(C->dp[14]);
|
||||
/* 15 */
|
||||
COMBA_FORWARD;
|
||||
MULADD(at[0], at[39]); MULADD(at[1], at[38]); MULADD(at[2], at[37]); MULADD(at[3], at[36]); MULADD(at[4], at[35]); MULADD(at[5], at[34]); MULADD(at[6], at[33]); MULADD(at[7], at[32]); MULADD(at[8], at[31]); MULADD(at[9], at[30]); MULADD(at[10], at[29]); MULADD(at[11], at[28]); MULADD(at[12], at[27]); MULADD(at[13], at[26]); MULADD(at[14], at[25]); MULADD(at[15], at[24]);
|
||||
COMBA_STORE(C->dp[15]);
|
||||
/* 16 */
|
||||
COMBA_FORWARD;
|
||||
MULADD(at[0], at[40]); MULADD(at[1], at[39]); MULADD(at[2], at[38]); MULADD(at[3], at[37]); MULADD(at[4], at[36]); MULADD(at[5], at[35]); MULADD(at[6], at[34]); MULADD(at[7], at[33]); MULADD(at[8], at[32]); MULADD(at[9], at[31]); MULADD(at[10], at[30]); MULADD(at[11], at[29]); MULADD(at[12], at[28]); MULADD(at[13], at[27]); MULADD(at[14], at[26]); MULADD(at[15], at[25]); MULADD(at[16], at[24]);
|
||||
COMBA_STORE(C->dp[16]);
|
||||
/* 17 */
|
||||
COMBA_FORWARD;
|
||||
MULADD(at[0], at[41]); MULADD(at[1], at[40]); MULADD(at[2], at[39]); MULADD(at[3], at[38]); MULADD(at[4], at[37]); MULADD(at[5], at[36]); MULADD(at[6], at[35]); MULADD(at[7], at[34]); MULADD(at[8], at[33]); MULADD(at[9], at[32]); MULADD(at[10], at[31]); MULADD(at[11], at[30]); MULADD(at[12], at[29]); MULADD(at[13], at[28]); MULADD(at[14], at[27]); MULADD(at[15], at[26]); MULADD(at[16], at[25]); MULADD(at[17], at[24]);
|
||||
COMBA_STORE(C->dp[17]);
|
||||
/* 18 */
|
||||
COMBA_FORWARD;
|
||||
MULADD(at[0], at[42]); MULADD(at[1], at[41]); MULADD(at[2], at[40]); MULADD(at[3], at[39]); MULADD(at[4], at[38]); MULADD(at[5], at[37]); MULADD(at[6], at[36]); MULADD(at[7], at[35]); MULADD(at[8], at[34]); MULADD(at[9], at[33]); MULADD(at[10], at[32]); MULADD(at[11], at[31]); MULADD(at[12], at[30]); MULADD(at[13], at[29]); MULADD(at[14], at[28]); MULADD(at[15], at[27]); MULADD(at[16], at[26]); MULADD(at[17], at[25]); MULADD(at[18], at[24]);
|
||||
COMBA_STORE(C->dp[18]);
|
||||
/* 19 */
|
||||
COMBA_FORWARD;
|
||||
MULADD(at[0], at[43]); MULADD(at[1], at[42]); MULADD(at[2], at[41]); MULADD(at[3], at[40]); MULADD(at[4], at[39]); MULADD(at[5], at[38]); MULADD(at[6], at[37]); MULADD(at[7], at[36]); MULADD(at[8], at[35]); MULADD(at[9], at[34]); MULADD(at[10], at[33]); MULADD(at[11], at[32]); MULADD(at[12], at[31]); MULADD(at[13], at[30]); MULADD(at[14], at[29]); MULADD(at[15], at[28]); MULADD(at[16], at[27]); MULADD(at[17], at[26]); MULADD(at[18], at[25]); MULADD(at[19], at[24]);
|
||||
COMBA_STORE(C->dp[19]);
|
||||
/* 20 */
|
||||
COMBA_FORWARD;
|
||||
MULADD(at[0], at[44]); MULADD(at[1], at[43]); MULADD(at[2], at[42]); MULADD(at[3], at[41]); MULADD(at[4], at[40]); MULADD(at[5], at[39]); MULADD(at[6], at[38]); MULADD(at[7], at[37]); MULADD(at[8], at[36]); MULADD(at[9], at[35]); MULADD(at[10], at[34]); MULADD(at[11], at[33]); MULADD(at[12], at[32]); MULADD(at[13], at[31]); MULADD(at[14], at[30]); MULADD(at[15], at[29]); MULADD(at[16], at[28]); MULADD(at[17], at[27]); MULADD(at[18], at[26]); MULADD(at[19], at[25]); MULADD(at[20], at[24]);
|
||||
COMBA_STORE(C->dp[20]);
|
||||
/* 21 */
|
||||
COMBA_FORWARD;
|
||||
MULADD(at[0], at[45]); MULADD(at[1], at[44]); MULADD(at[2], at[43]); MULADD(at[3], at[42]); MULADD(at[4], at[41]); MULADD(at[5], at[40]); MULADD(at[6], at[39]); MULADD(at[7], at[38]); MULADD(at[8], at[37]); MULADD(at[9], at[36]); MULADD(at[10], at[35]); MULADD(at[11], at[34]); MULADD(at[12], at[33]); MULADD(at[13], at[32]); MULADD(at[14], at[31]); MULADD(at[15], at[30]); MULADD(at[16], at[29]); MULADD(at[17], at[28]); MULADD(at[18], at[27]); MULADD(at[19], at[26]); MULADD(at[20], at[25]); MULADD(at[21], at[24]);
|
||||
COMBA_STORE(C->dp[21]);
|
||||
/* 22 */
|
||||
COMBA_FORWARD;
|
||||
MULADD(at[0], at[46]); MULADD(at[1], at[45]); MULADD(at[2], at[44]); MULADD(at[3], at[43]); MULADD(at[4], at[42]); MULADD(at[5], at[41]); MULADD(at[6], at[40]); MULADD(at[7], at[39]); MULADD(at[8], at[38]); MULADD(at[9], at[37]); MULADD(at[10], at[36]); MULADD(at[11], at[35]); MULADD(at[12], at[34]); MULADD(at[13], at[33]); MULADD(at[14], at[32]); MULADD(at[15], at[31]); MULADD(at[16], at[30]); MULADD(at[17], at[29]); MULADD(at[18], at[28]); MULADD(at[19], at[27]); MULADD(at[20], at[26]); MULADD(at[21], at[25]); MULADD(at[22], at[24]);
|
||||
COMBA_STORE(C->dp[22]);
|
||||
/* 23 */
|
||||
COMBA_FORWARD;
|
||||
MULADD(at[0], at[47]); MULADD(at[1], at[46]); MULADD(at[2], at[45]); MULADD(at[3], at[44]); MULADD(at[4], at[43]); MULADD(at[5], at[42]); MULADD(at[6], at[41]); MULADD(at[7], at[40]); MULADD(at[8], at[39]); MULADD(at[9], at[38]); MULADD(at[10], at[37]); MULADD(at[11], at[36]); MULADD(at[12], at[35]); MULADD(at[13], at[34]); MULADD(at[14], at[33]); MULADD(at[15], at[32]); MULADD(at[16], at[31]); MULADD(at[17], at[30]); MULADD(at[18], at[29]); MULADD(at[19], at[28]); MULADD(at[20], at[27]); MULADD(at[21], at[26]); MULADD(at[22], at[25]); MULADD(at[23], at[24]);
|
||||
COMBA_STORE(C->dp[23]);
|
||||
/* 24 */
|
||||
COMBA_FORWARD;
|
||||
MULADD(at[1], at[47]); MULADD(at[2], at[46]); MULADD(at[3], at[45]); MULADD(at[4], at[44]); MULADD(at[5], at[43]); MULADD(at[6], at[42]); MULADD(at[7], at[41]); MULADD(at[8], at[40]); MULADD(at[9], at[39]); MULADD(at[10], at[38]); MULADD(at[11], at[37]); MULADD(at[12], at[36]); MULADD(at[13], at[35]); MULADD(at[14], at[34]); MULADD(at[15], at[33]); MULADD(at[16], at[32]); MULADD(at[17], at[31]); MULADD(at[18], at[30]); MULADD(at[19], at[29]); MULADD(at[20], at[28]); MULADD(at[21], at[27]); MULADD(at[22], at[26]); MULADD(at[23], at[25]);
|
||||
COMBA_STORE(C->dp[24]);
|
||||
/* 25 */
|
||||
COMBA_FORWARD;
|
||||
MULADD(at[2], at[47]); MULADD(at[3], at[46]); MULADD(at[4], at[45]); MULADD(at[5], at[44]); MULADD(at[6], at[43]); MULADD(at[7], at[42]); MULADD(at[8], at[41]); MULADD(at[9], at[40]); MULADD(at[10], at[39]); MULADD(at[11], at[38]); MULADD(at[12], at[37]); MULADD(at[13], at[36]); MULADD(at[14], at[35]); MULADD(at[15], at[34]); MULADD(at[16], at[33]); MULADD(at[17], at[32]); MULADD(at[18], at[31]); MULADD(at[19], at[30]); MULADD(at[20], at[29]); MULADD(at[21], at[28]); MULADD(at[22], at[27]); MULADD(at[23], at[26]);
|
||||
COMBA_STORE(C->dp[25]);
|
||||
/* 26 */
|
||||
COMBA_FORWARD;
|
||||
MULADD(at[3], at[47]); MULADD(at[4], at[46]); MULADD(at[5], at[45]); MULADD(at[6], at[44]); MULADD(at[7], at[43]); MULADD(at[8], at[42]); MULADD(at[9], at[41]); MULADD(at[10], at[40]); MULADD(at[11], at[39]); MULADD(at[12], at[38]); MULADD(at[13], at[37]); MULADD(at[14], at[36]); MULADD(at[15], at[35]); MULADD(at[16], at[34]); MULADD(at[17], at[33]); MULADD(at[18], at[32]); MULADD(at[19], at[31]); MULADD(at[20], at[30]); MULADD(at[21], at[29]); MULADD(at[22], at[28]); MULADD(at[23], at[27]);
|
||||
COMBA_STORE(C->dp[26]);
|
||||
/* 27 */
|
||||
COMBA_FORWARD;
|
||||
MULADD(at[4], at[47]); MULADD(at[5], at[46]); MULADD(at[6], at[45]); MULADD(at[7], at[44]); MULADD(at[8], at[43]); MULADD(at[9], at[42]); MULADD(at[10], at[41]); MULADD(at[11], at[40]); MULADD(at[12], at[39]); MULADD(at[13], at[38]); MULADD(at[14], at[37]); MULADD(at[15], at[36]); MULADD(at[16], at[35]); MULADD(at[17], at[34]); MULADD(at[18], at[33]); MULADD(at[19], at[32]); MULADD(at[20], at[31]); MULADD(at[21], at[30]); MULADD(at[22], at[29]); MULADD(at[23], at[28]);
|
||||
COMBA_STORE(C->dp[27]);
|
||||
/* 28 */
|
||||
COMBA_FORWARD;
|
||||
MULADD(at[5], at[47]); MULADD(at[6], at[46]); MULADD(at[7], at[45]); MULADD(at[8], at[44]); MULADD(at[9], at[43]); MULADD(at[10], at[42]); MULADD(at[11], at[41]); MULADD(at[12], at[40]); MULADD(at[13], at[39]); MULADD(at[14], at[38]); MULADD(at[15], at[37]); MULADD(at[16], at[36]); MULADD(at[17], at[35]); MULADD(at[18], at[34]); MULADD(at[19], at[33]); MULADD(at[20], at[32]); MULADD(at[21], at[31]); MULADD(at[22], at[30]); MULADD(at[23], at[29]);
|
||||
COMBA_STORE(C->dp[28]);
|
||||
/* 29 */
|
||||
COMBA_FORWARD;
|
||||
MULADD(at[6], at[47]); MULADD(at[7], at[46]); MULADD(at[8], at[45]); MULADD(at[9], at[44]); MULADD(at[10], at[43]); MULADD(at[11], at[42]); MULADD(at[12], at[41]); MULADD(at[13], at[40]); MULADD(at[14], at[39]); MULADD(at[15], at[38]); MULADD(at[16], at[37]); MULADD(at[17], at[36]); MULADD(at[18], at[35]); MULADD(at[19], at[34]); MULADD(at[20], at[33]); MULADD(at[21], at[32]); MULADD(at[22], at[31]); MULADD(at[23], at[30]);
|
||||
COMBA_STORE(C->dp[29]);
|
||||
/* 30 */
|
||||
COMBA_FORWARD;
|
||||
MULADD(at[7], at[47]); MULADD(at[8], at[46]); MULADD(at[9], at[45]); MULADD(at[10], at[44]); MULADD(at[11], at[43]); MULADD(at[12], at[42]); MULADD(at[13], at[41]); MULADD(at[14], at[40]); MULADD(at[15], at[39]); MULADD(at[16], at[38]); MULADD(at[17], at[37]); MULADD(at[18], at[36]); MULADD(at[19], at[35]); MULADD(at[20], at[34]); MULADD(at[21], at[33]); MULADD(at[22], at[32]); MULADD(at[23], at[31]);
|
||||
COMBA_STORE(C->dp[30]);
|
||||
/* 31 */
|
||||
COMBA_FORWARD;
|
||||
MULADD(at[8], at[47]); MULADD(at[9], at[46]); MULADD(at[10], at[45]); MULADD(at[11], at[44]); MULADD(at[12], at[43]); MULADD(at[13], at[42]); MULADD(at[14], at[41]); MULADD(at[15], at[40]); MULADD(at[16], at[39]); MULADD(at[17], at[38]); MULADD(at[18], at[37]); MULADD(at[19], at[36]); MULADD(at[20], at[35]); MULADD(at[21], at[34]); MULADD(at[22], at[33]); MULADD(at[23], at[32]);
|
||||
COMBA_STORE(C->dp[31]);
|
||||
/* 32 */
|
||||
COMBA_FORWARD;
|
||||
MULADD(at[9], at[47]); MULADD(at[10], at[46]); MULADD(at[11], at[45]); MULADD(at[12], at[44]); MULADD(at[13], at[43]); MULADD(at[14], at[42]); MULADD(at[15], at[41]); MULADD(at[16], at[40]); MULADD(at[17], at[39]); MULADD(at[18], at[38]); MULADD(at[19], at[37]); MULADD(at[20], at[36]); MULADD(at[21], at[35]); MULADD(at[22], at[34]); MULADD(at[23], at[33]);
|
||||
COMBA_STORE(C->dp[32]);
|
||||
/* 33 */
|
||||
COMBA_FORWARD;
|
||||
MULADD(at[10], at[47]); MULADD(at[11], at[46]); MULADD(at[12], at[45]); MULADD(at[13], at[44]); MULADD(at[14], at[43]); MULADD(at[15], at[42]); MULADD(at[16], at[41]); MULADD(at[17], at[40]); MULADD(at[18], at[39]); MULADD(at[19], at[38]); MULADD(at[20], at[37]); MULADD(at[21], at[36]); MULADD(at[22], at[35]); MULADD(at[23], at[34]);
|
||||
COMBA_STORE(C->dp[33]);
|
||||
/* 34 */
|
||||
COMBA_FORWARD;
|
||||
MULADD(at[11], at[47]); MULADD(at[12], at[46]); MULADD(at[13], at[45]); MULADD(at[14], at[44]); MULADD(at[15], at[43]); MULADD(at[16], at[42]); MULADD(at[17], at[41]); MULADD(at[18], at[40]); MULADD(at[19], at[39]); MULADD(at[20], at[38]); MULADD(at[21], at[37]); MULADD(at[22], at[36]); MULADD(at[23], at[35]);
|
||||
COMBA_STORE(C->dp[34]);
|
||||
/* 35 */
|
||||
COMBA_FORWARD;
|
||||
MULADD(at[12], at[47]); MULADD(at[13], at[46]); MULADD(at[14], at[45]); MULADD(at[15], at[44]); MULADD(at[16], at[43]); MULADD(at[17], at[42]); MULADD(at[18], at[41]); MULADD(at[19], at[40]); MULADD(at[20], at[39]); MULADD(at[21], at[38]); MULADD(at[22], at[37]); MULADD(at[23], at[36]);
|
||||
COMBA_STORE(C->dp[35]);
|
||||
/* 36 */
|
||||
COMBA_FORWARD;
|
||||
MULADD(at[13], at[47]); MULADD(at[14], at[46]); MULADD(at[15], at[45]); MULADD(at[16], at[44]); MULADD(at[17], at[43]); MULADD(at[18], at[42]); MULADD(at[19], at[41]); MULADD(at[20], at[40]); MULADD(at[21], at[39]); MULADD(at[22], at[38]); MULADD(at[23], at[37]);
|
||||
COMBA_STORE(C->dp[36]);
|
||||
/* 37 */
|
||||
COMBA_FORWARD;
|
||||
MULADD(at[14], at[47]); MULADD(at[15], at[46]); MULADD(at[16], at[45]); MULADD(at[17], at[44]); MULADD(at[18], at[43]); MULADD(at[19], at[42]); MULADD(at[20], at[41]); MULADD(at[21], at[40]); MULADD(at[22], at[39]); MULADD(at[23], at[38]);
|
||||
COMBA_STORE(C->dp[37]);
|
||||
/* 38 */
|
||||
COMBA_FORWARD;
|
||||
MULADD(at[15], at[47]); MULADD(at[16], at[46]); MULADD(at[17], at[45]); MULADD(at[18], at[44]); MULADD(at[19], at[43]); MULADD(at[20], at[42]); MULADD(at[21], at[41]); MULADD(at[22], at[40]); MULADD(at[23], at[39]);
|
||||
COMBA_STORE(C->dp[38]);
|
||||
/* 39 */
|
||||
COMBA_FORWARD;
|
||||
MULADD(at[16], at[47]); MULADD(at[17], at[46]); MULADD(at[18], at[45]); MULADD(at[19], at[44]); MULADD(at[20], at[43]); MULADD(at[21], at[42]); MULADD(at[22], at[41]); MULADD(at[23], at[40]);
|
||||
COMBA_STORE(C->dp[39]);
|
||||
/* 40 */
|
||||
COMBA_FORWARD;
|
||||
MULADD(at[17], at[47]); MULADD(at[18], at[46]); MULADD(at[19], at[45]); MULADD(at[20], at[44]); MULADD(at[21], at[43]); MULADD(at[22], at[42]); MULADD(at[23], at[41]);
|
||||
COMBA_STORE(C->dp[40]);
|
||||
/* 41 */
|
||||
COMBA_FORWARD;
|
||||
MULADD(at[18], at[47]); MULADD(at[19], at[46]); MULADD(at[20], at[45]); MULADD(at[21], at[44]); MULADD(at[22], at[43]); MULADD(at[23], at[42]);
|
||||
COMBA_STORE(C->dp[41]);
|
||||
/* 42 */
|
||||
COMBA_FORWARD;
|
||||
MULADD(at[19], at[47]); MULADD(at[20], at[46]); MULADD(at[21], at[45]); MULADD(at[22], at[44]); MULADD(at[23], at[43]);
|
||||
COMBA_STORE(C->dp[42]);
|
||||
/* 43 */
|
||||
COMBA_FORWARD;
|
||||
MULADD(at[20], at[47]); MULADD(at[21], at[46]); MULADD(at[22], at[45]); MULADD(at[23], at[44]);
|
||||
COMBA_STORE(C->dp[43]);
|
||||
/* 44 */
|
||||
COMBA_FORWARD;
|
||||
MULADD(at[21], at[47]); MULADD(at[22], at[46]); MULADD(at[23], at[45]);
|
||||
COMBA_STORE(C->dp[44]);
|
||||
/* 45 */
|
||||
COMBA_FORWARD;
|
||||
MULADD(at[22], at[47]); MULADD(at[23], at[46]);
|
||||
COMBA_STORE(C->dp[45]);
|
||||
/* 46 */
|
||||
COMBA_FORWARD;
|
||||
MULADD(at[23], at[47]);
|
||||
COMBA_STORE(C->dp[46]);
|
||||
COMBA_STORE2(C->dp[47]);
|
||||
C->used = 48;
|
||||
C->sign = A->sign ^ B->sign;
|
||||
fp_clamp(C);
|
||||
COMBA_FINI;
|
||||
|
||||
#ifdef WOLFSSL_SMALL_STACK
|
||||
XFREE(at, NULL, DYNAMIC_TYPE_TMP_BUFFER);
|
||||
#endif
|
||||
return FP_OKAY;
|
||||
}
|
||||
#endif
|
@ -1,275 +0,0 @@
|
||||
/* fp_mul_comba_28.i
|
||||
*
|
||||
* Copyright (C) 2006-2020 wolfSSL Inc.
|
||||
*
|
||||
* This file is part of wolfSSL.
|
||||
*
|
||||
* wolfSSL is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* wolfSSL is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA
|
||||
*/
|
||||
|
||||
|
||||
|
||||
#ifdef TFM_MUL28
|
||||
int fp_mul_comba28(fp_int *A, fp_int *B, fp_int *C)
|
||||
{
|
||||
fp_digit c0, c1, c2;
|
||||
#ifndef WOLFSSL_SMALL_STACK
|
||||
fp_digit at[56];
|
||||
#else
|
||||
fp_digit *at;
|
||||
#endif
|
||||
|
||||
#ifdef WOLFSSL_SMALL_STACK
|
||||
at = (fp_digit*)XMALLOC(sizeof(fp_digit) * 56, NULL, DYNAMIC_TYPE_TMP_BUFFER);
|
||||
if (at == NULL)
|
||||
return FP_MEM;
|
||||
#endif
|
||||
|
||||
XMEMCPY(at, A->dp, 28 * sizeof(fp_digit));
|
||||
XMEMCPY(at+28, B->dp, 28 * sizeof(fp_digit));
|
||||
COMBA_START;
|
||||
|
||||
COMBA_CLEAR;
|
||||
/* 0 */
|
||||
MULADD(at[0], at[28]);
|
||||
COMBA_STORE(C->dp[0]);
|
||||
/* 1 */
|
||||
COMBA_FORWARD;
|
||||
MULADD(at[0], at[29]); MULADD(at[1], at[28]);
|
||||
COMBA_STORE(C->dp[1]);
|
||||
/* 2 */
|
||||
COMBA_FORWARD;
|
||||
MULADD(at[0], at[30]); MULADD(at[1], at[29]); MULADD(at[2], at[28]);
|
||||
COMBA_STORE(C->dp[2]);
|
||||
/* 3 */
|
||||
COMBA_FORWARD;
|
||||
MULADD(at[0], at[31]); MULADD(at[1], at[30]); MULADD(at[2], at[29]); MULADD(at[3], at[28]);
|
||||
COMBA_STORE(C->dp[3]);
|
||||
/* 4 */
|
||||
COMBA_FORWARD;
|
||||
MULADD(at[0], at[32]); MULADD(at[1], at[31]); MULADD(at[2], at[30]); MULADD(at[3], at[29]); MULADD(at[4], at[28]);
|
||||
COMBA_STORE(C->dp[4]);
|
||||
/* 5 */
|
||||
COMBA_FORWARD;
|
||||
MULADD(at[0], at[33]); MULADD(at[1], at[32]); MULADD(at[2], at[31]); MULADD(at[3], at[30]); MULADD(at[4], at[29]); MULADD(at[5], at[28]);
|
||||
COMBA_STORE(C->dp[5]);
|
||||
/* 6 */
|
||||
COMBA_FORWARD;
|
||||
MULADD(at[0], at[34]); MULADD(at[1], at[33]); MULADD(at[2], at[32]); MULADD(at[3], at[31]); MULADD(at[4], at[30]); MULADD(at[5], at[29]); MULADD(at[6], at[28]);
|
||||
COMBA_STORE(C->dp[6]);
|
||||
/* 7 */
|
||||
COMBA_FORWARD;
|
||||
MULADD(at[0], at[35]); MULADD(at[1], at[34]); MULADD(at[2], at[33]); MULADD(at[3], at[32]); MULADD(at[4], at[31]); MULADD(at[5], at[30]); MULADD(at[6], at[29]); MULADD(at[7], at[28]);
|
||||
COMBA_STORE(C->dp[7]);
|
||||
/* 8 */
|
||||
COMBA_FORWARD;
|
||||
MULADD(at[0], at[36]); MULADD(at[1], at[35]); MULADD(at[2], at[34]); MULADD(at[3], at[33]); MULADD(at[4], at[32]); MULADD(at[5], at[31]); MULADD(at[6], at[30]); MULADD(at[7], at[29]); MULADD(at[8], at[28]);
|
||||
COMBA_STORE(C->dp[8]);
|
||||
/* 9 */
|
||||
COMBA_FORWARD;
|
||||
MULADD(at[0], at[37]); MULADD(at[1], at[36]); MULADD(at[2], at[35]); MULADD(at[3], at[34]); MULADD(at[4], at[33]); MULADD(at[5], at[32]); MULADD(at[6], at[31]); MULADD(at[7], at[30]); MULADD(at[8], at[29]); MULADD(at[9], at[28]);
|
||||
COMBA_STORE(C->dp[9]);
|
||||
/* 10 */
|
||||
COMBA_FORWARD;
|
||||
MULADD(at[0], at[38]); MULADD(at[1], at[37]); MULADD(at[2], at[36]); MULADD(at[3], at[35]); MULADD(at[4], at[34]); MULADD(at[5], at[33]); MULADD(at[6], at[32]); MULADD(at[7], at[31]); MULADD(at[8], at[30]); MULADD(at[9], at[29]); MULADD(at[10], at[28]);
|
||||
COMBA_STORE(C->dp[10]);
|
||||
/* 11 */
|
||||
COMBA_FORWARD;
|
||||
MULADD(at[0], at[39]); MULADD(at[1], at[38]); MULADD(at[2], at[37]); MULADD(at[3], at[36]); MULADD(at[4], at[35]); MULADD(at[5], at[34]); MULADD(at[6], at[33]); MULADD(at[7], at[32]); MULADD(at[8], at[31]); MULADD(at[9], at[30]); MULADD(at[10], at[29]); MULADD(at[11], at[28]);
|
||||
COMBA_STORE(C->dp[11]);
|
||||
/* 12 */
|
||||
COMBA_FORWARD;
|
||||
MULADD(at[0], at[40]); MULADD(at[1], at[39]); MULADD(at[2], at[38]); MULADD(at[3], at[37]); MULADD(at[4], at[36]); MULADD(at[5], at[35]); MULADD(at[6], at[34]); MULADD(at[7], at[33]); MULADD(at[8], at[32]); MULADD(at[9], at[31]); MULADD(at[10], at[30]); MULADD(at[11], at[29]); MULADD(at[12], at[28]);
|
||||
COMBA_STORE(C->dp[12]);
|
||||
/* 13 */
|
||||
COMBA_FORWARD;
|
||||
MULADD(at[0], at[41]); MULADD(at[1], at[40]); MULADD(at[2], at[39]); MULADD(at[3], at[38]); MULADD(at[4], at[37]); MULADD(at[5], at[36]); MULADD(at[6], at[35]); MULADD(at[7], at[34]); MULADD(at[8], at[33]); MULADD(at[9], at[32]); MULADD(at[10], at[31]); MULADD(at[11], at[30]); MULADD(at[12], at[29]); MULADD(at[13], at[28]);
|
||||
COMBA_STORE(C->dp[13]);
|
||||
/* 14 */
|
||||
COMBA_FORWARD;
|
||||
MULADD(at[0], at[42]); MULADD(at[1], at[41]); MULADD(at[2], at[40]); MULADD(at[3], at[39]); MULADD(at[4], at[38]); MULADD(at[5], at[37]); MULADD(at[6], at[36]); MULADD(at[7], at[35]); MULADD(at[8], at[34]); MULADD(at[9], at[33]); MULADD(at[10], at[32]); MULADD(at[11], at[31]); MULADD(at[12], at[30]); MULADD(at[13], at[29]); MULADD(at[14], at[28]);
|
||||
COMBA_STORE(C->dp[14]);
|
||||
/* 15 */
|
||||
COMBA_FORWARD;
|
||||
MULADD(at[0], at[43]); MULADD(at[1], at[42]); MULADD(at[2], at[41]); MULADD(at[3], at[40]); MULADD(at[4], at[39]); MULADD(at[5], at[38]); MULADD(at[6], at[37]); MULADD(at[7], at[36]); MULADD(at[8], at[35]); MULADD(at[9], at[34]); MULADD(at[10], at[33]); MULADD(at[11], at[32]); MULADD(at[12], at[31]); MULADD(at[13], at[30]); MULADD(at[14], at[29]); MULADD(at[15], at[28]);
|
||||
COMBA_STORE(C->dp[15]);
|
||||
/* 16 */
|
||||
COMBA_FORWARD;
|
||||
MULADD(at[0], at[44]); MULADD(at[1], at[43]); MULADD(at[2], at[42]); MULADD(at[3], at[41]); MULADD(at[4], at[40]); MULADD(at[5], at[39]); MULADD(at[6], at[38]); MULADD(at[7], at[37]); MULADD(at[8], at[36]); MULADD(at[9], at[35]); MULADD(at[10], at[34]); MULADD(at[11], at[33]); MULADD(at[12], at[32]); MULADD(at[13], at[31]); MULADD(at[14], at[30]); MULADD(at[15], at[29]); MULADD(at[16], at[28]);
|
||||
COMBA_STORE(C->dp[16]);
|
||||
/* 17 */
|
||||
COMBA_FORWARD;
|
||||
MULADD(at[0], at[45]); MULADD(at[1], at[44]); MULADD(at[2], at[43]); MULADD(at[3], at[42]); MULADD(at[4], at[41]); MULADD(at[5], at[40]); MULADD(at[6], at[39]); MULADD(at[7], at[38]); MULADD(at[8], at[37]); MULADD(at[9], at[36]); MULADD(at[10], at[35]); MULADD(at[11], at[34]); MULADD(at[12], at[33]); MULADD(at[13], at[32]); MULADD(at[14], at[31]); MULADD(at[15], at[30]); MULADD(at[16], at[29]); MULADD(at[17], at[28]);
|
||||
COMBA_STORE(C->dp[17]);
|
||||
/* 18 */
|
||||
COMBA_FORWARD;
|
||||
MULADD(at[0], at[46]); MULADD(at[1], at[45]); MULADD(at[2], at[44]); MULADD(at[3], at[43]); MULADD(at[4], at[42]); MULADD(at[5], at[41]); MULADD(at[6], at[40]); MULADD(at[7], at[39]); MULADD(at[8], at[38]); MULADD(at[9], at[37]); MULADD(at[10], at[36]); MULADD(at[11], at[35]); MULADD(at[12], at[34]); MULADD(at[13], at[33]); MULADD(at[14], at[32]); MULADD(at[15], at[31]); MULADD(at[16], at[30]); MULADD(at[17], at[29]); MULADD(at[18], at[28]);
|
||||
COMBA_STORE(C->dp[18]);
|
||||
/* 19 */
|
||||
COMBA_FORWARD;
|
||||
MULADD(at[0], at[47]); MULADD(at[1], at[46]); MULADD(at[2], at[45]); MULADD(at[3], at[44]); MULADD(at[4], at[43]); MULADD(at[5], at[42]); MULADD(at[6], at[41]); MULADD(at[7], at[40]); MULADD(at[8], at[39]); MULADD(at[9], at[38]); MULADD(at[10], at[37]); MULADD(at[11], at[36]); MULADD(at[12], at[35]); MULADD(at[13], at[34]); MULADD(at[14], at[33]); MULADD(at[15], at[32]); MULADD(at[16], at[31]); MULADD(at[17], at[30]); MULADD(at[18], at[29]); MULADD(at[19], at[28]);
|
||||
COMBA_STORE(C->dp[19]);
|
||||
/* 20 */
|
||||
COMBA_FORWARD;
|
||||
MULADD(at[0], at[48]); MULADD(at[1], at[47]); MULADD(at[2], at[46]); MULADD(at[3], at[45]); MULADD(at[4], at[44]); MULADD(at[5], at[43]); MULADD(at[6], at[42]); MULADD(at[7], at[41]); MULADD(at[8], at[40]); MULADD(at[9], at[39]); MULADD(at[10], at[38]); MULADD(at[11], at[37]); MULADD(at[12], at[36]); MULADD(at[13], at[35]); MULADD(at[14], at[34]); MULADD(at[15], at[33]); MULADD(at[16], at[32]); MULADD(at[17], at[31]); MULADD(at[18], at[30]); MULADD(at[19], at[29]); MULADD(at[20], at[28]);
|
||||
COMBA_STORE(C->dp[20]);
|
||||
/* 21 */
|
||||
COMBA_FORWARD;
|
||||
MULADD(at[0], at[49]); MULADD(at[1], at[48]); MULADD(at[2], at[47]); MULADD(at[3], at[46]); MULADD(at[4], at[45]); MULADD(at[5], at[44]); MULADD(at[6], at[43]); MULADD(at[7], at[42]); MULADD(at[8], at[41]); MULADD(at[9], at[40]); MULADD(at[10], at[39]); MULADD(at[11], at[38]); MULADD(at[12], at[37]); MULADD(at[13], at[36]); MULADD(at[14], at[35]); MULADD(at[15], at[34]); MULADD(at[16], at[33]); MULADD(at[17], at[32]); MULADD(at[18], at[31]); MULADD(at[19], at[30]); MULADD(at[20], at[29]); MULADD(at[21], at[28]);
|
||||
COMBA_STORE(C->dp[21]);
|
||||
/* 22 */
|
||||
COMBA_FORWARD;
|
||||
MULADD(at[0], at[50]); MULADD(at[1], at[49]); MULADD(at[2], at[48]); MULADD(at[3], at[47]); MULADD(at[4], at[46]); MULADD(at[5], at[45]); MULADD(at[6], at[44]); MULADD(at[7], at[43]); MULADD(at[8], at[42]); MULADD(at[9], at[41]); MULADD(at[10], at[40]); MULADD(at[11], at[39]); MULADD(at[12], at[38]); MULADD(at[13], at[37]); MULADD(at[14], at[36]); MULADD(at[15], at[35]); MULADD(at[16], at[34]); MULADD(at[17], at[33]); MULADD(at[18], at[32]); MULADD(at[19], at[31]); MULADD(at[20], at[30]); MULADD(at[21], at[29]); MULADD(at[22], at[28]);
|
||||
COMBA_STORE(C->dp[22]);
|
||||
/* 23 */
|
||||
COMBA_FORWARD;
|
||||
MULADD(at[0], at[51]); MULADD(at[1], at[50]); MULADD(at[2], at[49]); MULADD(at[3], at[48]); MULADD(at[4], at[47]); MULADD(at[5], at[46]); MULADD(at[6], at[45]); MULADD(at[7], at[44]); MULADD(at[8], at[43]); MULADD(at[9], at[42]); MULADD(at[10], at[41]); MULADD(at[11], at[40]); MULADD(at[12], at[39]); MULADD(at[13], at[38]); MULADD(at[14], at[37]); MULADD(at[15], at[36]); MULADD(at[16], at[35]); MULADD(at[17], at[34]); MULADD(at[18], at[33]); MULADD(at[19], at[32]); MULADD(at[20], at[31]); MULADD(at[21], at[30]); MULADD(at[22], at[29]); MULADD(at[23], at[28]);
|
||||
COMBA_STORE(C->dp[23]);
|
||||
/* 24 */
|
||||
COMBA_FORWARD;
|
||||
MULADD(at[0], at[52]); MULADD(at[1], at[51]); MULADD(at[2], at[50]); MULADD(at[3], at[49]); MULADD(at[4], at[48]); MULADD(at[5], at[47]); MULADD(at[6], at[46]); MULADD(at[7], at[45]); MULADD(at[8], at[44]); MULADD(at[9], at[43]); MULADD(at[10], at[42]); MULADD(at[11], at[41]); MULADD(at[12], at[40]); MULADD(at[13], at[39]); MULADD(at[14], at[38]); MULADD(at[15], at[37]); MULADD(at[16], at[36]); MULADD(at[17], at[35]); MULADD(at[18], at[34]); MULADD(at[19], at[33]); MULADD(at[20], at[32]); MULADD(at[21], at[31]); MULADD(at[22], at[30]); MULADD(at[23], at[29]); MULADD(at[24], at[28]);
|
||||
COMBA_STORE(C->dp[24]);
|
||||
/* 25 */
|
||||
COMBA_FORWARD;
|
||||
MULADD(at[0], at[53]); MULADD(at[1], at[52]); MULADD(at[2], at[51]); MULADD(at[3], at[50]); MULADD(at[4], at[49]); MULADD(at[5], at[48]); MULADD(at[6], at[47]); MULADD(at[7], at[46]); MULADD(at[8], at[45]); MULADD(at[9], at[44]); MULADD(at[10], at[43]); MULADD(at[11], at[42]); MULADD(at[12], at[41]); MULADD(at[13], at[40]); MULADD(at[14], at[39]); MULADD(at[15], at[38]); MULADD(at[16], at[37]); MULADD(at[17], at[36]); MULADD(at[18], at[35]); MULADD(at[19], at[34]); MULADD(at[20], at[33]); MULADD(at[21], at[32]); MULADD(at[22], at[31]); MULADD(at[23], at[30]); MULADD(at[24], at[29]); MULADD(at[25], at[28]);
|
||||
COMBA_STORE(C->dp[25]);
|
||||
/* 26 */
|
||||
COMBA_FORWARD;
|
||||
MULADD(at[0], at[54]); MULADD(at[1], at[53]); MULADD(at[2], at[52]); MULADD(at[3], at[51]); MULADD(at[4], at[50]); MULADD(at[5], at[49]); MULADD(at[6], at[48]); MULADD(at[7], at[47]); MULADD(at[8], at[46]); MULADD(at[9], at[45]); MULADD(at[10], at[44]); MULADD(at[11], at[43]); MULADD(at[12], at[42]); MULADD(at[13], at[41]); MULADD(at[14], at[40]); MULADD(at[15], at[39]); MULADD(at[16], at[38]); MULADD(at[17], at[37]); MULADD(at[18], at[36]); MULADD(at[19], at[35]); MULADD(at[20], at[34]); MULADD(at[21], at[33]); MULADD(at[22], at[32]); MULADD(at[23], at[31]); MULADD(at[24], at[30]); MULADD(at[25], at[29]); MULADD(at[26], at[28]);
|
||||
COMBA_STORE(C->dp[26]);
|
||||
/* 27 */
|
||||
COMBA_FORWARD;
|
||||
MULADD(at[0], at[55]); MULADD(at[1], at[54]); MULADD(at[2], at[53]); MULADD(at[3], at[52]); MULADD(at[4], at[51]); MULADD(at[5], at[50]); MULADD(at[6], at[49]); MULADD(at[7], at[48]); MULADD(at[8], at[47]); MULADD(at[9], at[46]); MULADD(at[10], at[45]); MULADD(at[11], at[44]); MULADD(at[12], at[43]); MULADD(at[13], at[42]); MULADD(at[14], at[41]); MULADD(at[15], at[40]); MULADD(at[16], at[39]); MULADD(at[17], at[38]); MULADD(at[18], at[37]); MULADD(at[19], at[36]); MULADD(at[20], at[35]); MULADD(at[21], at[34]); MULADD(at[22], at[33]); MULADD(at[23], at[32]); MULADD(at[24], at[31]); MULADD(at[25], at[30]); MULADD(at[26], at[29]); MULADD(at[27], at[28]);
|
||||
COMBA_STORE(C->dp[27]);
|
||||
/* 28 */
|
||||
COMBA_FORWARD;
|
||||
MULADD(at[1], at[55]); MULADD(at[2], at[54]); MULADD(at[3], at[53]); MULADD(at[4], at[52]); MULADD(at[5], at[51]); MULADD(at[6], at[50]); MULADD(at[7], at[49]); MULADD(at[8], at[48]); MULADD(at[9], at[47]); MULADD(at[10], at[46]); MULADD(at[11], at[45]); MULADD(at[12], at[44]); MULADD(at[13], at[43]); MULADD(at[14], at[42]); MULADD(at[15], at[41]); MULADD(at[16], at[40]); MULADD(at[17], at[39]); MULADD(at[18], at[38]); MULADD(at[19], at[37]); MULADD(at[20], at[36]); MULADD(at[21], at[35]); MULADD(at[22], at[34]); MULADD(at[23], at[33]); MULADD(at[24], at[32]); MULADD(at[25], at[31]); MULADD(at[26], at[30]); MULADD(at[27], at[29]);
|
||||
COMBA_STORE(C->dp[28]);
|
||||
/* 29 */
|
||||
COMBA_FORWARD;
|
||||
MULADD(at[2], at[55]); MULADD(at[3], at[54]); MULADD(at[4], at[53]); MULADD(at[5], at[52]); MULADD(at[6], at[51]); MULADD(at[7], at[50]); MULADD(at[8], at[49]); MULADD(at[9], at[48]); MULADD(at[10], at[47]); MULADD(at[11], at[46]); MULADD(at[12], at[45]); MULADD(at[13], at[44]); MULADD(at[14], at[43]); MULADD(at[15], at[42]); MULADD(at[16], at[41]); MULADD(at[17], at[40]); MULADD(at[18], at[39]); MULADD(at[19], at[38]); MULADD(at[20], at[37]); MULADD(at[21], at[36]); MULADD(at[22], at[35]); MULADD(at[23], at[34]); MULADD(at[24], at[33]); MULADD(at[25], at[32]); MULADD(at[26], at[31]); MULADD(at[27], at[30]);
|
||||
COMBA_STORE(C->dp[29]);
|
||||
/* 30 */
|
||||
COMBA_FORWARD;
|
||||
MULADD(at[3], at[55]); MULADD(at[4], at[54]); MULADD(at[5], at[53]); MULADD(at[6], at[52]); MULADD(at[7], at[51]); MULADD(at[8], at[50]); MULADD(at[9], at[49]); MULADD(at[10], at[48]); MULADD(at[11], at[47]); MULADD(at[12], at[46]); MULADD(at[13], at[45]); MULADD(at[14], at[44]); MULADD(at[15], at[43]); MULADD(at[16], at[42]); MULADD(at[17], at[41]); MULADD(at[18], at[40]); MULADD(at[19], at[39]); MULADD(at[20], at[38]); MULADD(at[21], at[37]); MULADD(at[22], at[36]); MULADD(at[23], at[35]); MULADD(at[24], at[34]); MULADD(at[25], at[33]); MULADD(at[26], at[32]); MULADD(at[27], at[31]);
|
||||
COMBA_STORE(C->dp[30]);
|
||||
/* 31 */
|
||||
COMBA_FORWARD;
|
||||
MULADD(at[4], at[55]); MULADD(at[5], at[54]); MULADD(at[6], at[53]); MULADD(at[7], at[52]); MULADD(at[8], at[51]); MULADD(at[9], at[50]); MULADD(at[10], at[49]); MULADD(at[11], at[48]); MULADD(at[12], at[47]); MULADD(at[13], at[46]); MULADD(at[14], at[45]); MULADD(at[15], at[44]); MULADD(at[16], at[43]); MULADD(at[17], at[42]); MULADD(at[18], at[41]); MULADD(at[19], at[40]); MULADD(at[20], at[39]); MULADD(at[21], at[38]); MULADD(at[22], at[37]); MULADD(at[23], at[36]); MULADD(at[24], at[35]); MULADD(at[25], at[34]); MULADD(at[26], at[33]); MULADD(at[27], at[32]);
|
||||
COMBA_STORE(C->dp[31]);
|
||||
/* 32 */
|
||||
COMBA_FORWARD;
|
||||
MULADD(at[5], at[55]); MULADD(at[6], at[54]); MULADD(at[7], at[53]); MULADD(at[8], at[52]); MULADD(at[9], at[51]); MULADD(at[10], at[50]); MULADD(at[11], at[49]); MULADD(at[12], at[48]); MULADD(at[13], at[47]); MULADD(at[14], at[46]); MULADD(at[15], at[45]); MULADD(at[16], at[44]); MULADD(at[17], at[43]); MULADD(at[18], at[42]); MULADD(at[19], at[41]); MULADD(at[20], at[40]); MULADD(at[21], at[39]); MULADD(at[22], at[38]); MULADD(at[23], at[37]); MULADD(at[24], at[36]); MULADD(at[25], at[35]); MULADD(at[26], at[34]); MULADD(at[27], at[33]);
|
||||
COMBA_STORE(C->dp[32]);
|
||||
/* 33 */
|
||||
COMBA_FORWARD;
|
||||
MULADD(at[6], at[55]); MULADD(at[7], at[54]); MULADD(at[8], at[53]); MULADD(at[9], at[52]); MULADD(at[10], at[51]); MULADD(at[11], at[50]); MULADD(at[12], at[49]); MULADD(at[13], at[48]); MULADD(at[14], at[47]); MULADD(at[15], at[46]); MULADD(at[16], at[45]); MULADD(at[17], at[44]); MULADD(at[18], at[43]); MULADD(at[19], at[42]); MULADD(at[20], at[41]); MULADD(at[21], at[40]); MULADD(at[22], at[39]); MULADD(at[23], at[38]); MULADD(at[24], at[37]); MULADD(at[25], at[36]); MULADD(at[26], at[35]); MULADD(at[27], at[34]);
|
||||
COMBA_STORE(C->dp[33]);
|
||||
/* 34 */
|
||||
COMBA_FORWARD;
|
||||
MULADD(at[7], at[55]); MULADD(at[8], at[54]); MULADD(at[9], at[53]); MULADD(at[10], at[52]); MULADD(at[11], at[51]); MULADD(at[12], at[50]); MULADD(at[13], at[49]); MULADD(at[14], at[48]); MULADD(at[15], at[47]); MULADD(at[16], at[46]); MULADD(at[17], at[45]); MULADD(at[18], at[44]); MULADD(at[19], at[43]); MULADD(at[20], at[42]); MULADD(at[21], at[41]); MULADD(at[22], at[40]); MULADD(at[23], at[39]); MULADD(at[24], at[38]); MULADD(at[25], at[37]); MULADD(at[26], at[36]); MULADD(at[27], at[35]);
|
||||
COMBA_STORE(C->dp[34]);
|
||||
/* 35 */
|
||||
COMBA_FORWARD;
|
||||
MULADD(at[8], at[55]); MULADD(at[9], at[54]); MULADD(at[10], at[53]); MULADD(at[11], at[52]); MULADD(at[12], at[51]); MULADD(at[13], at[50]); MULADD(at[14], at[49]); MULADD(at[15], at[48]); MULADD(at[16], at[47]); MULADD(at[17], at[46]); MULADD(at[18], at[45]); MULADD(at[19], at[44]); MULADD(at[20], at[43]); MULADD(at[21], at[42]); MULADD(at[22], at[41]); MULADD(at[23], at[40]); MULADD(at[24], at[39]); MULADD(at[25], at[38]); MULADD(at[26], at[37]); MULADD(at[27], at[36]);
|
||||
COMBA_STORE(C->dp[35]);
|
||||
/* 36 */
|
||||
COMBA_FORWARD;
|
||||
MULADD(at[9], at[55]); MULADD(at[10], at[54]); MULADD(at[11], at[53]); MULADD(at[12], at[52]); MULADD(at[13], at[51]); MULADD(at[14], at[50]); MULADD(at[15], at[49]); MULADD(at[16], at[48]); MULADD(at[17], at[47]); MULADD(at[18], at[46]); MULADD(at[19], at[45]); MULADD(at[20], at[44]); MULADD(at[21], at[43]); MULADD(at[22], at[42]); MULADD(at[23], at[41]); MULADD(at[24], at[40]); MULADD(at[25], at[39]); MULADD(at[26], at[38]); MULADD(at[27], at[37]);
|
||||
COMBA_STORE(C->dp[36]);
|
||||
/* 37 */
|
||||
COMBA_FORWARD;
|
||||
MULADD(at[10], at[55]); MULADD(at[11], at[54]); MULADD(at[12], at[53]); MULADD(at[13], at[52]); MULADD(at[14], at[51]); MULADD(at[15], at[50]); MULADD(at[16], at[49]); MULADD(at[17], at[48]); MULADD(at[18], at[47]); MULADD(at[19], at[46]); MULADD(at[20], at[45]); MULADD(at[21], at[44]); MULADD(at[22], at[43]); MULADD(at[23], at[42]); MULADD(at[24], at[41]); MULADD(at[25], at[40]); MULADD(at[26], at[39]); MULADD(at[27], at[38]);
|
||||
COMBA_STORE(C->dp[37]);
|
||||
/* 38 */
|
||||
COMBA_FORWARD;
|
||||
MULADD(at[11], at[55]); MULADD(at[12], at[54]); MULADD(at[13], at[53]); MULADD(at[14], at[52]); MULADD(at[15], at[51]); MULADD(at[16], at[50]); MULADD(at[17], at[49]); MULADD(at[18], at[48]); MULADD(at[19], at[47]); MULADD(at[20], at[46]); MULADD(at[21], at[45]); MULADD(at[22], at[44]); MULADD(at[23], at[43]); MULADD(at[24], at[42]); MULADD(at[25], at[41]); MULADD(at[26], at[40]); MULADD(at[27], at[39]);
|
||||
COMBA_STORE(C->dp[38]);
|
||||
/* 39 */
|
||||
COMBA_FORWARD;
|
||||
MULADD(at[12], at[55]); MULADD(at[13], at[54]); MULADD(at[14], at[53]); MULADD(at[15], at[52]); MULADD(at[16], at[51]); MULADD(at[17], at[50]); MULADD(at[18], at[49]); MULADD(at[19], at[48]); MULADD(at[20], at[47]); MULADD(at[21], at[46]); MULADD(at[22], at[45]); MULADD(at[23], at[44]); MULADD(at[24], at[43]); MULADD(at[25], at[42]); MULADD(at[26], at[41]); MULADD(at[27], at[40]);
|
||||
COMBA_STORE(C->dp[39]);
|
||||
/* 40 */
|
||||
COMBA_FORWARD;
|
||||
MULADD(at[13], at[55]); MULADD(at[14], at[54]); MULADD(at[15], at[53]); MULADD(at[16], at[52]); MULADD(at[17], at[51]); MULADD(at[18], at[50]); MULADD(at[19], at[49]); MULADD(at[20], at[48]); MULADD(at[21], at[47]); MULADD(at[22], at[46]); MULADD(at[23], at[45]); MULADD(at[24], at[44]); MULADD(at[25], at[43]); MULADD(at[26], at[42]); MULADD(at[27], at[41]);
|
||||
COMBA_STORE(C->dp[40]);
|
||||
/* 41 */
|
||||
COMBA_FORWARD;
|
||||
MULADD(at[14], at[55]); MULADD(at[15], at[54]); MULADD(at[16], at[53]); MULADD(at[17], at[52]); MULADD(at[18], at[51]); MULADD(at[19], at[50]); MULADD(at[20], at[49]); MULADD(at[21], at[48]); MULADD(at[22], at[47]); MULADD(at[23], at[46]); MULADD(at[24], at[45]); MULADD(at[25], at[44]); MULADD(at[26], at[43]); MULADD(at[27], at[42]);
|
||||
COMBA_STORE(C->dp[41]);
|
||||
/* 42 */
|
||||
COMBA_FORWARD;
|
||||
MULADD(at[15], at[55]); MULADD(at[16], at[54]); MULADD(at[17], at[53]); MULADD(at[18], at[52]); MULADD(at[19], at[51]); MULADD(at[20], at[50]); MULADD(at[21], at[49]); MULADD(at[22], at[48]); MULADD(at[23], at[47]); MULADD(at[24], at[46]); MULADD(at[25], at[45]); MULADD(at[26], at[44]); MULADD(at[27], at[43]);
|
||||
COMBA_STORE(C->dp[42]);
|
||||
/* 43 */
|
||||
COMBA_FORWARD;
|
||||
MULADD(at[16], at[55]); MULADD(at[17], at[54]); MULADD(at[18], at[53]); MULADD(at[19], at[52]); MULADD(at[20], at[51]); MULADD(at[21], at[50]); MULADD(at[22], at[49]); MULADD(at[23], at[48]); MULADD(at[24], at[47]); MULADD(at[25], at[46]); MULADD(at[26], at[45]); MULADD(at[27], at[44]);
|
||||
COMBA_STORE(C->dp[43]);
|
||||
/* 44 */
|
||||
COMBA_FORWARD;
|
||||
MULADD(at[17], at[55]); MULADD(at[18], at[54]); MULADD(at[19], at[53]); MULADD(at[20], at[52]); MULADD(at[21], at[51]); MULADD(at[22], at[50]); MULADD(at[23], at[49]); MULADD(at[24], at[48]); MULADD(at[25], at[47]); MULADD(at[26], at[46]); MULADD(at[27], at[45]);
|
||||
COMBA_STORE(C->dp[44]);
|
||||
/* 45 */
|
||||
COMBA_FORWARD;
|
||||
MULADD(at[18], at[55]); MULADD(at[19], at[54]); MULADD(at[20], at[53]); MULADD(at[21], at[52]); MULADD(at[22], at[51]); MULADD(at[23], at[50]); MULADD(at[24], at[49]); MULADD(at[25], at[48]); MULADD(at[26], at[47]); MULADD(at[27], at[46]);
|
||||
COMBA_STORE(C->dp[45]);
|
||||
/* 46 */
|
||||
COMBA_FORWARD;
|
||||
MULADD(at[19], at[55]); MULADD(at[20], at[54]); MULADD(at[21], at[53]); MULADD(at[22], at[52]); MULADD(at[23], at[51]); MULADD(at[24], at[50]); MULADD(at[25], at[49]); MULADD(at[26], at[48]); MULADD(at[27], at[47]);
|
||||
COMBA_STORE(C->dp[46]);
|
||||
/* 47 */
|
||||
COMBA_FORWARD;
|
||||
MULADD(at[20], at[55]); MULADD(at[21], at[54]); MULADD(at[22], at[53]); MULADD(at[23], at[52]); MULADD(at[24], at[51]); MULADD(at[25], at[50]); MULADD(at[26], at[49]); MULADD(at[27], at[48]);
|
||||
COMBA_STORE(C->dp[47]);
|
||||
/* 48 */
|
||||
COMBA_FORWARD;
|
||||
MULADD(at[21], at[55]); MULADD(at[22], at[54]); MULADD(at[23], at[53]); MULADD(at[24], at[52]); MULADD(at[25], at[51]); MULADD(at[26], at[50]); MULADD(at[27], at[49]);
|
||||
COMBA_STORE(C->dp[48]);
|
||||
/* 49 */
|
||||
COMBA_FORWARD;
|
||||
MULADD(at[22], at[55]); MULADD(at[23], at[54]); MULADD(at[24], at[53]); MULADD(at[25], at[52]); MULADD(at[26], at[51]); MULADD(at[27], at[50]);
|
||||
COMBA_STORE(C->dp[49]);
|
||||
/* 50 */
|
||||
COMBA_FORWARD;
|
||||
MULADD(at[23], at[55]); MULADD(at[24], at[54]); MULADD(at[25], at[53]); MULADD(at[26], at[52]); MULADD(at[27], at[51]);
|
||||
COMBA_STORE(C->dp[50]);
|
||||
/* 51 */
|
||||
COMBA_FORWARD;
|
||||
MULADD(at[24], at[55]); MULADD(at[25], at[54]); MULADD(at[26], at[53]); MULADD(at[27], at[52]);
|
||||
COMBA_STORE(C->dp[51]);
|
||||
/* 52 */
|
||||
COMBA_FORWARD;
|
||||
MULADD(at[25], at[55]); MULADD(at[26], at[54]); MULADD(at[27], at[53]);
|
||||
COMBA_STORE(C->dp[52]);
|
||||
/* 53 */
|
||||
COMBA_FORWARD;
|
||||
MULADD(at[26], at[55]); MULADD(at[27], at[54]);
|
||||
COMBA_STORE(C->dp[53]);
|
||||
/* 54 */
|
||||
COMBA_FORWARD;
|
||||
MULADD(at[27], at[55]);
|
||||
COMBA_STORE(C->dp[54]);
|
||||
COMBA_STORE2(C->dp[55]);
|
||||
C->used = 56;
|
||||
C->sign = A->sign ^ B->sign;
|
||||
fp_clamp(C);
|
||||
COMBA_FINI;
|
||||
|
||||
#ifdef WOLFSSL_SMALL_STACK
|
||||
XFREE(at, NULL, DYNAMIC_TYPE_TMP_BUFFER);
|
||||
#endif
|
||||
return FP_OKAY;
|
||||
}
|
||||
#endif
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue